【发布时间】:2014-01-24 03:56:05
【问题描述】:
我正在使用 spring JMSTemplate 连接到不同 weblogic 域上的队列。
我在 Spring 配置中连接了所有组件,如 jndiTemplate、connectionfactory、destination 等。
消息由 MessageListener 的简单实现处理。
一切正常。但是,当我尝试在目的地不可用的地方部署此应用程序时,部署失败。这对我来说非常重要,因为我们的某些环境中没有 JMS 基础架构。
我尝试在所有组件上使用 lookupOnStartup=false,并尝试根据环境变量将它们注入 DMLC。但问题是,听众似乎没有启动。所有消息都留在队列中。
非常感谢任何帮助。
弹簧配置:
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://wp2128.xyz.int:7001</prop>
<prop key="java.naming.security.authentication">none</prop>
<prop key="java.naming.security.principal"></prop>
</props>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" >
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="jms/connectionFactory" />
</bean>
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="jndiName" value="jms/testQueue" />
</bean>
<bean id="simpleConsumer"
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="5" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="destination" />
<property name="messageListener" ref="simpleMessageListener" />
</bean>
【问题讨论】:
-
您可以使用 Spring 配置文件在测试环境中删除有问题的 bean。 spring.io/blog/2011/02/11/spring-framework-3-1-m1-released 参见“输入 bean 定义配置文件”
-
这里是另一个链接,也提到了 Evgeni 提到的使用配置文件进行条件启动的内容:stackoverflow.com/questions/8279270/…
标签: java spring spring-mvc jms weblogic