我最终切换到使用 lib/optional 目录中的 activemq 提供的资源适配器。
如果有人有兴趣,这是我为使其工作而遵循的步骤
asadmin create-resource-adapter-config --property ServerUrl=failover\:(tcp\://localhost\:61616,tcp\://localhost\:61617) activemqra
asadmin deploy --name activemqra <path to activemq-rar-5.4.2.rar>
然后创建资源:
asadmin create-connector-connection-pool --raname --connectiondefinition javax.jms.ConnectionFactory --transactionsupport XATransaction jms/MyQueueFactoryPool
asadmin create-connector-resource --poolname jms/MyQueueFactoryPool jms/MyQueueQFactory
asadmin create-admin-object --raname activemqra --restype javax.jms.Queue --property PhysicalName=MyQueue jms/MyQueue
要连接 mdb,我必须在 sun-ejb-jar.xml 中添加它
<mdb-resource-adapter>
<resource-adapter-mid>activemqra</resource-adapter-mid>
<activation-config>
<activation-config-property>
<activation-config-property-name>DestinationType
</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue
</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destination
</activation-config-property-name>
<activation-config-property-value>MyQueue
</activation-config-property-value>
</activation-config-property>
</activation-config>
</mdb-resource-adapter>
要将其连接到 spring JMSTemplate:
<bean id="ConFac" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jms/MyQueueQQFactory</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean>
<bean id="myqueue" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jms/MyQueue</value>
</property>
<property name="resourceRef">
<value>true</value>
</property>
</bean>
<bean id="mdbTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="conFac" />
<property name="defaultDestination" ref="myqueue" />
</bean>