Servlet to remote ActiveMQ
I'm trying to send a message using JMS from a servlet (running on Apache Tomcat) to ActiveMQ running in a different VM on the same system.
Things i have tried:
- Running ActiveMQ on my system.
- Wrote a client (Java app) (Producer) to create messages.
- Wrote a client (Java app) (Consumer) to receive those messages.
The above setup works fine.
Now, i have a servlet, which looks up the resources via JNDI. This is the configuration of context.xml in META-INF directory of Tomcat.
<Context>
<Resource
name="jms/ConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL=" tcp://localhost:61616"
/>
</Context>
I'm able to lookup these resources from the sevlet. The message is sent. But i think it is not reaching the ActiveMQ. Any ideas why ?
I feel it is sending it to some other destination v开发者_Go百科m://localhost
running within the container? which is not what i want. I'm new to MOM.
If someone could tell me how to send a JMS message from a servlet to a remote Broker, it would be great.
If you are looking up the connection via JNDI that is pointed at an ActiveMQ instance at tcp://localhost:61616, that is not a remote broker. That is a broker running on the local machine on port 61616. If you want the connection to made to a remote broker on another machine, then replace localhost with the IP address.
Bruce
精彩评论