Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can easily integrate the RealTime Messaging Module with Tomcat and ActiveMQ.
Next, we're going to explain the most important part of this integration.

1. Setup RealTime Messaging Module.
You need to configure the server.properties configuration file of your application. The basic configuration of this file should be as follow:

Code Block
---server.properties----
messaging.dispatcherImplementer: com.isomorphic.messaging.JMSMessageDispatcher
jndi.messaging.java.naming.factory.initial: org.apache.activemq.jndi.ActiveMQInitialContextFactory
jndi.messaging.java.naming.provider.url: tcp://hostname:61616
messaging.jms.context: _container_
messaging.jms.jndiPrefix:
messaging.jms.topicConnectionFactory: jms/ConnectionFactory


2. Configure Tomcat with ActiveMQ.
Next, you need to configure the context.xml configuration file of your Tomcat server. This file is located in the path <HOME_TOMCAT>/conf/. Use this configuration If you are using Tomcat 5.5 or later.

Code Block
---context.xml----
<Resource auth="Container"
name="jms/ConnectionFactory"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
useEmbeddedBroker="false"
brokerName="localhost"/>

<Resource auth="Container"
name="chatChannel"
type="org.apache.activemq.command.ActiveMQTopic"
description="JMS Topic"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="chatChannel"/>

3. Setup ActiveMQ.
For an independent installation you can refer here.
If you prefer to run ActiveMQ inside of Tomcat, use the previous configuration and consider these settings:

Code Block
---server.properties----
jndi.messaging.java.naming.provider.url: vm://localhost

...

Code Block
---context.xml----
<Resource auth="Container"
name="jms/ConnectionFactory"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="vm://localhost"
useEmbeddedBroker="true"
brokerName="localhost"/>

However, when using the embedded option, you only need to add to the Tomcat's lib folder the following jars:
activemq-all-5.5.1.jar
slf4j-log4j12-1.5.11.jar
log4j-1.2.14.jar
slf4j-api-1.5.11.jar

4. Setup your application.
You only need to add the activemq-all-5.5.1.jar library to your application.

This configuration was tested with Apache ActiveMQ v 5.5.1 and Tomcat v. 7.0.16.