Send activemq message to CarnotApplicationQuque [message #990535] |
Wed, 12 December 2012 18:10  |
Eclipse User |
|
|
|
Hi, I am trying to send message to CarnotApplicationQuque using following code.
Hashtable props = new Hashtable();
props.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.put("java.naming.provider.url", "tcp://bulldog:2057");
Context messaging = new InitialContext(props);
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) messaging.lookup("java:comp/env/jms/CarnotXAConnectionFactory");
Queue queue = (Queue) messaging.lookup("java:comp/env/jms/CarnotApplicationQueue");
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();
QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
QueueSender sender = queueSession.createSender(queue);
TextMessage message = queueSession.createTextMessage();
message.setText("Hello World");
sender.send(message);
I am getting following error message. Any idea?
012-12-12 16:10:00.104|Info| |main|Main|Initializing message consumer...
javax.naming.NameNotFoundException: CarnotXAConnectionFactory
at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at ca.uleth.jms.Main.main(Main.java:81)
|
|
|
Re: Send activemq message to CarnotApplicationQuque [message #990629 is a reply to message #990535] |
Thu, 13 December 2012 09:01  |
Eclipse User |
|
|
|
Hi Rahim,
it's likely that the name for the JNDI lookup is wrong and you should double-check under what name the connection factory is available.
This depends on your deployment. Since you're using ActiveMQ, my guess is you have a Spring WAR deployment and you should find the Stardust Spring context files that assemble and publish the connection factory. Also check your context.xml and web.xml if there are resource-ref entries that expose the connection factory under a different name.
In case you're deploying your code within the same WAR as the Stardust engine, the simplest thing would be to wrap your code into a Spring bean and inject a reference to the connection factory bean directly. This would eliminate the need for a JNDI lookup. (That is assuming you are using a Spring-based deployment).
Best regards,
Jan
|
|
|
Powered by
FUDForum. Page generated in 0.27006 seconds