【问题标题】:Configuring ActiveMQ with Spring vs JNDI lookup使用 Spring 与 JNDI 查找配置 ActiveMQ
【发布时间】:2013-02-28 19:00:17
【问题描述】:

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

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

【问题讨论】:

    标签: spring activemq


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-21
      • 1970-01-01
      • 2017-06-15
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-13
      相关资源
      最近更新 更多