Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to send messag to JMS Queue using Java

890740Jun 22 2012 — edited Jun 29 2012
Hi all,

I am trying to send a string to the JMS queue using java. I am unable to send the message. It is getting failed at the look up for connection factory. I am using the below code for this purpose.



public static void messageEnqueue(String payload) throws JMSException,
NamingException,
IOException {

Session session = null;
MessageProducer publisher = null;
TextMessage message = null;
Context context = new InitialContext();
QueueConnectionFactory connectionFactory =
(QueueConnectionFactory)context.lookup("*java:comp/env/XAConnectionFactoryJNDIName*");
Connection connection = connectionFactory.createConnection();
Queue Queue1 =
(Queue)context.lookup("*java:comp/env/QueueName*");
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
publisher = session.createProducer(Queue1);

message = session.createTextMessage(Payload);


connection.start();
publisher.send(message);
connection.stop();
connection.close();

}
}


kindly help on this.

Thanks

Edited by: 887737 on Jun 28, 2012 9:47 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2012
Added on Jun 22 2012
14 comments
6,655 views