Configuration issues for Tomcat 7 and later
Warning |
| Tomcat needs to be configured to ignore Jetty SCI annotations so that the Jetty WebSocket ServerContainerInitializer class is not inadvertently picked up by Tomcat. For information on information on this problem see AMQ-6154 and https://wiki.apache.org/tomcat/HowTo/FasterStartUp |
Pre-integrated Tomcat with ActiveMQ ... Something like the following works out of the box with no configuration:
Code Block |
import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import javax.jms.Topic;
import javax.jms.Queue;
import javax.jms.ConnectionFactory;
public class MyServet extends HttpServlet {
@Resource(name = "foo")
private Topic fooTopic;
@Resource(name = "bar")
private Queue barQueue;
@Resource
private ConnectionFactory connectionFactory;
|
... You must provide it as a parameter factory for your resources:
Code Block |
<Context ...>
...
<Resource name="jms/ConnectionFactory" auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"/>
<ResourceParams name="jms/ConnectionFactory">
<parameter>
<name>factory</name>
<value>org.activemq.jndi.JNDIReferenceFactory</value>
</parameter>
<parameter>
<name>brokerURL</name>
<value>vm://localhost</value>
</parameter>
<parameter>
<name>brokerName</name>
<value>LocalActiveMQBroker</value>
</parameter>
<parameter>
<name>useEmbeddedBroker</name>
<value>true</value>
</parameter>
</ResourceParams>
...
</Context>
|
... If you are using Tomcat 5.5 or later then try this instead...
Code Block |
<Context>
...
<Resource name="jms/ConnectionFactory" auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" brokerURL="vm://localhost" brokerName="LocalActiveMQBroker"/>
....
</Context>
|
... This is completely untested but should work ![(smile)]()
Code Block |
<Context>
...
<Resource name="jms/someTopic" auth="Container" type="org.apache.activemq.command.ActiveMQTopic" description="my Topic"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR"/>
<Resource name="jms/aQueue" auth="Container" type="org.apache.activemq.command.ActiveMQQueue" description="my Queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="FOO.BAR"/>
....
</Context>
|
Info |
| title |
JMX Tip when working with Tomcat |
|
| If you want to use JMX with Tomcat and then connect via JConsole to view the JMX MBeans of the server then set the following
Code Block |
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 \
-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
|
|
|