Spring Tomcat 服务器尝试读取 Foriegn Weblogic JMS 主题时未调用 MessageListener

Spring MessageListener not invoked in Tomcat Server when trying to read a Foriegn Weblogic JMS Topic

我已经在 Tomcat7 中部署了一个应用程序来从 Weblogic 11g 中的 Foreign JMS Topic 读取消息。这是我的 spring 应用程序上下文 xml。我已将 wlthint3client.jar 包含在我的类路径中。

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:c="http://www.springframework.org/schema/c"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:jms="http://www.springframework.org/schema/jms"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.0.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

 <!-- Uncomment and add your base-package here: <context:component-scan base-package="org.springframework.samples.service"/> -->
 <tx:jta-transaction-manager/>
 <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager" p:connectionFactory-ref="clarifyconnectionFactory"/>
 <bean id="clarifyTopic" class="org.springframework.jndi.JndiObjectFactoryBean"
  p:jndiName="jms/ATomcatClarifyTopic"
  p:proxyInterface="javax.jms.Destination"
  p:jndiTemplate-ref="jndiTemplate"/>
 <bean id="messageAdapter" class="org.springframework.jms.listener.adapter.MessageListenerAdapter" p:defaultListenerMethod="receive">
 <constructor-arg>
  <bean class="com.jnpr.clarify.jms.DefaultTextMessageDelegate"/>
 </constructor-arg>
 </bean> 
 <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://weblogichost:8001</prop>
   </props>
  </property>
 </bean>
 <!-- Lookup JMS Connection Factory -->
 <bean id="clarifyconnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"
  p:jndiName="jms/TestTopicConnectionFactory" p:proxyInterface="javax.jms.TopicConnectionFactory"
  p:jndiTemplate-ref="jndiTemplate"
  p:exposeAccessContext="true"/>

  <!-- Configuring JMS Template -->
 <bean id='jmsTemplate' class="org.springframework.jms.core.JmsTemplate"
  c:_0-ref="clarifyconnectionFactory" />

 <!-- Configuring Topic Listener -->
 <bean id="topicListener" class="com.jnpr.clarify.jms.TopicListener" />

 <!-- Configuring MessageListenerContainer -->
 <bean id="JMSMessageListenerContainer"
  class="org.springframework.jms.listener.DefaultMessageListenerContainer"
  p:destination-ref="clarifyTopic" p:connectionFactory-ref="clarifyconnectionFactory"
  p:messageListener-ref="messageAdapter" p:transactionManager-ref="jmsTransactionManager"
  p:durableSubscriptionName="TomcatClarify"/>
</beans>

如果做错了请帮忙。

当消息侦听器容器使用如下 jms 命名空间而不是常规 spring bean 配置时,以上代码有效。

<jms:listener-container container-type="default" acknowledge="auto"
 connection-factory="clarifyconnectionFactory" destination-type="durableTopic"
 destination-resolver="jmsDestinationResolver">
  <jms:listener destination="jms/ATomcatClarifyTopic" ref="topicListener"/>
 </jms:listener-container>  
 <bean id="jmsDestinationResolver"
        class="org.springframework.jms.support.destination.JndiDestinationResolver">
 <property name="jndiTemplate">
  <ref bean="jndiTemplate" />
 </property>
 <property name="cache">
  <value>true</value>
 </property>
 </bean>