1. 資源上下文客戶端設定
Apache ActiveMQ Artemis 支援在 Tomcat 容器的 context.xml
中設定客戶端。
這與在 ActiveMQ "Classic" 中設定的方式非常相似,因此任何正在遷移的使用者都應該會覺得很熟悉。請注意,ActiveMQ Artemis 的連接 URL 和可以設定的屬性有所不同,請參閱遷移文件
1.1. 連接工廠範例
<Context>
...
<Resource name="jms/ConnectionFactory" auth="Container" type="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory" description="JMS Connection Factory"
factory="org.apache.activemq.artemis.jndi.JNDIReferenceFactory" brokerURL="tcp://127.0.0.1:61616" />
...
</Context>
1.2. 目的地範例 (佇列和主題)
<Context>
...
<Resource name="jms/ExampleQueue" auth="Container" type="org.apache.activemq.artemis.jms.client.ActiveMQQueue" description="JMS Queue"
factory="org.apache.activemq.artemis.jndi.JNDIReferenceFactory" address="ExampleQueue" />
...
<Resource name="jms/ExampleTopic" auth="Container" type="org.apache.activemq.artemis.jms.client.ActiveMQTopic" description="JMS Topic"
factory="org.apache.activemq.artemis.jndi.JNDIReferenceFactory" address="ExampleTopic" />
...
</Context>
2. Tomcat 應用程式範例
這裡可以看到一個範例 Tomcat 應用程式,其中容器上下文已設定為範例
/examples/features/sub-modules/tomcat