Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating ActiveMQ with Tomcat

I am looking for tips on integrating activemq with tomcat.

My architecture looks like below where each app is running on a different jvm/machines,

producer app -> tomcat (activemq) -> consumer app

The consumers and producers should connect to activemq on a remote machine. I would also like to have the web console enabled.

like image 570
josh Avatar asked Oct 31 '25 01:10

josh


1 Answers

First you should download and install ActiveMQ on remote machine, web console will be enabled by default.

Second you should configure each tomcat node.

Put activemq-all.jar (version 5.11 and higher, you can download here http://mvnrepository.com/artifact/org.apache.activemq/activemq-all) into $TOMCAT_HOME/lib folder. ActiveMQ has ready JNDI resource factory for all its administered objects: ConnectionFactory and destinations. You must provide it as a parameter factory for your resources:

Add to $TOMCAT_HOME/CONF/context.xml

<Resource name="jms/activemq-factory" 
        auth="Container" 
        type="org.apache.activemq.ActiveMQConnectionFactory" 
        description="JMS Connection Factory" 
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
        brokerURL="tcp://${broker.host}:${broker.port}" 
        brokerName="LocalActiveMQBroker" 
        useEmbeddedBroker="false"/>

<Resource name="jms/activemq-topic" 
            auth="Container" 
            type="org.apache.activemq.command.ActiveMQTopic" 
            factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
            physicalName="activemq-topic"/> 

replace broker.host and broker.port to real ActiveMQ parameters.

Now you can write consumers for acticvemq-topic. Thats all.

like image 56
Anton Ilinchik Avatar answered Nov 02 '25 15:11

Anton Ilinchik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!