2012-06-11 125 views
1

我試圖獲得一個運行JMS的基本Spring集成配置。Spring與JMS配置的集成

問題是,我似乎正在進行連接(按照日誌),但我沒有收到我的話題的任何消息。

這是我的配置:

<!-- Channels --> 
<jms:channel id="inputChannel" queue-name="test.queue" connection-factory="connectionFactory"/> 

<!-- Consumers -->  
<jms:inbound-channel-adapter id="jmsIn" destination="requestQueue" channel="inputChannel" extract-payload="true" connection-factory="connectionFactory"> 
    <integration:poller time-unit="SECONDS" fixed-rate="5"/> 
</jms:inbound-channel-adapter> 

<integration:service-activator id="testActivator" input-channel="inputChannel" ref="testServiceActivator" auto-startup="true" method="handle"> 
</integration:service-activator> 

<!-- Bean definitions --> 
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory"> 
    <property name="targetConnectionFactory"> 
     <bean class="org.apache.activemq.ActiveMQConnectionFactory"> 
      <property name="brokerURL" value="tcp://127.0.0.1:61616"/>    
     </bean> 
    </property> 
    <property name="sessionCacheSize" value="10"/> 
    <property name="cacheProducers" value="false"/> 
</bean> 

<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue"> 
    <constructor-arg name="name" value="test.topic"/> 
</bean> 

<bean id="testServiceActivator" class="com.paddypower.financials.integration.PriceDistributionServiceActivator"/> 

我已經啓用DEBUG級別上的根記錄器和它說,jmsIn已成功啓動,並且它連接到ActiveMQ的服務器,但我沒有收到任何消息,請使用service-activatorinbound-channel-adapter

我還可以看到生產者正在通過ActiveMQ Web界面發送消息。

因此,任何人都可以看到任何配置錯誤或知道一種方式,我可以進一步調試它?

感謝,

+1

問題@Simeon:你提到「test.topic」是一個主題,請求隊列被定義爲一個隊列,但 - 任何理由爲什麼不ActiveMQTopic? –

+2

嘗試使用消息驅動通道適配器(反之通常更高效)並設置TRACE級別日誌記錄。 –

+0

@BijuKunjummen我剛剛發現它,你是對的,這是我改變了實現主題,現在一切正常的問題。添加一個答案,所以我可以接受它:) – Simeon

回答

2

ActiveMQQueueActiveMQTopic更改請求隊列的bean定義應該修復它。

<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQTopic"> 
    <constructor-arg name="name" value="test.topic"/> 
</bean> 
+4

爲了避免進一步的混淆,我還建議將bean重命名爲「requestTopic」;) – mfisher

+0

@mfisher完成。感謝您的高舉:) – Simeon