ActiveMQ与Tomcat集成

Tomcat提供了两种方式的JNDI Resource配置:

  • Local JNDI context:指该resource只可用于部署至该Tomcat容器中的某一个Application;
  • Global JNDI context.:指该resource客用于部署至Tomcat容器中的任何Application.

1. Using local JNDI to integrate ActiveMQ with Tomcat

    JNDI Resource配置位于META-INF/context.xml文件中:

<Context reloadable="true">
    <Resource auth="Container"
              name="jms/ConnectionFactory"
              type="org.apache.activemq.ActiveMQConnectionFactory"
              description="JMS Connection Factory"
              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
              brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
              brokerName="MyActiveMQBroker"/>

    <Resource auth="Container"
              name="jms/FooQueue"
              type="org.apache.activemq.command.ActiveMQQueue"
              description="JMS queue"
              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
              physicalName="FOO.QUEUE"/>

    <Resource auth="Container"
              name="jms/FooTopic"
              type="org.apache.activemq.command.ActiveMQTopic"
              description="JMS topic"
              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
              physicalName="FOO.TOPIC"/>
</Context>

2. Using global JNDI to integrate ActiveMQ with Tomcat

相关推荐