Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jms client  RSS feed

 
ranga shreya
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I have an assignment to write a jms client code. Sending an message from a servlet to a queue. getting the messages from the queue through messagedrivenbean.My question is Iam not abel to put the message through the servelt what might be the reason.
this is my code..
Context jndiContext = null;
ConnectionFactory connectionFactory = null;

Destination dest = null;
//ConnectionFactory connectionFactory = null;

try {
connectionFactory = (ConnectionFactory)
jndiContext.lookup("emailCf");
dest = (Destination) jndiContext.lookup("emailJmsQueue");
Connection connection =
connectionFactory.createConnection();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(dest);
TextMessage message = session.createTextMessage();
message.setText("This is message 1" );
System.out.println("Sending message: " +message.getText());
producer.send(message);



}
catch (Exception e) {
System.out.println("JNDI API lookup failed: " +
e.toString());
e.printStackTrace();
System.exit(1);
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!