使用Spring和JNDI查找配置ActiveMQ

时间:2013-02-27 22:05:27

标签: spring activemq

伙计 - 我有一个Spring 3.1,ActiveMQ 5.8& Tomcat7设置。

与配置工厂相比有什么优势吗? Spring中的队列与JNDI查找?

<amq:connectionFactory id="connectionFactory" brokerURL="tcp://localhost:61616"/>
<amq:queue id="queueOne" physicalName="TestQueueOne"/>
<amq:queue id="queueTwo" physicalName="TestQueueTwo"/>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory" />
</bean>

META-INF / context.xml中

<?xml version="1.0" encoding="UTF-8"?>
<Context>   
<Resource 
    name="jms/ConnectionFactory" 
    auth="Container"
    type="org.apache.activemq.ActiveMQConnectionFactory" 
    description="JMS Connection Factory"
    factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
    brokerURL="tcp://localhost:61616" />

<Resource 
    name="jms/QueueOne" 
    auth="Container"
    type="org.apache.activemq.command.ActiveMQQueue" 
    factory="org.apache.activemq.jndi.JNDIReferenceFactory"
    physicalName="TestQueueOne" />

<Resource 
    name="jms/QueueTwo" 
    auth="Container"
    type="org.apache.activemq.command.ActiveMQQueue" 
    factory="org.apache.activemq.jndi.JNDIReferenceFactory"
    physicalName="TestQueueTwo" />
</Context>  

我想知道一种方法是否比另一种“更好”?

1 个答案:

答案 0 :(得分:0)

根据您当前使用Tomcat的设置,可能还有Spring配置。如果您要转到使用完整的应用程序服务器,例如JBoss在某些时候可能会更好,因为你可以利用集群JNDI实现应用服务器提供的高可用性:

http://docs.jboss.org/jbossclustering/cluster_guide/5.1/html/clustering-jndi.html