开发者

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:

  1. Running ActiveMQ on my system.
  2. Wrote a client (Java app) (Producer) to create messages.
  3. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜