• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

P2P using WSAD's embedded JMS- Naming Exception

 
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using simple P2P using WSAD5.1.1 Test Server's embedded JMS.

I set up JMS tab of WSAD test server as:
Name JNDI Name
MyFactory jms/MyFactory
MyQueue jms/MyQueue
I checked MQ Simulator for Java Developer radio button.
I restarted Server.

My P2P program is:

public class SimpleQueueReceiver {

/**
* Main method.
*
* @param args the queue used by the example
*/
public static void main(String[] args) throws NamingException {
String queueName = "jms/MyQueue";
Context jndiContext = null;
QueueConnectionFactory queueConnectionFactory = null;
QueueConnection queueConnection = null;
QueueSession queueSession = null;
Queue queue = null;
QueueReceiver queueReceiver = null;
TextMessage message = null;

jndiContext = new InitialContext();
//TODO: NEED TO POPULATE context

queueConnectionFactory = (QueueConnectionFactory)jndiContext.lookup("jms/MyFactory");
queue = (Queue) jndiContext.lookup(queueName);

try {
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
queueReceiver = queueSession.createReceiver(queue);
queueConnection.start();
while (true) {
Message m = queueReceiver.receive(1);
if (m != null) {
if (m instanceof TextMessage) {
message = (TextMessage) m;
System.out.println("Reading message: " +
message.getText());
} else {
break;
}
}
}
} catch (JMSException e) {
System.out.println("Exception occurred: " +
e.toString());
} finally {
if (queueConnection != null) {
try {
queueConnection.close();
} catch (JMSException e) {}
}
}
}
}

I throws naming exception when trying to find factory. Am I missing anything else?
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic