2

伙计们-我有一个 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>  

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

4

1 回答 1

0

根据您当前使用 Tomcat 的设置,也许 Spring 配置是要走的路。如果您要转而使用成熟的应用程序服务器,例如 JBoss,那么 JNDI 可能会更好,因为您可以使用集群的 JNDI 来实现应用程序服务器提供的高可用性:

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

于 2013-02-28T11:00:17.277 回答