2015-11-03 46 views
1

我對Spring集成有以下情況的挑戰。我正在使用jms:outbound-channel-adapter,但檢查出站網關時我注意到有一些參數用於調整JMS隊列(顯式啓用qos,生存時間等),但問題在於「答覆偵聽器」,因爲應用程序在連接到其他服務器(其他網關)的多個服務器上運行,回覆消息可以由不是發送JMS消息的服務器的其他服務器處理。Spring集成JMS網關沒有回覆監聽器

我的疑惑是如何配置沒有任何「答覆偵聽器」的「出站網關」,這意味着沒有「答覆偵聽器」配置(既不會創建一個線程,也許永遠不會收到答覆,並會無任何理由地持有一個線程(監聽線程)。

閱讀文檔我明白這是不可能的。 這是真的嗎?就像沒有「回覆監聽器」一樣,沒有辦法使用出站網關?

回答

0

讓我引述JmsOutboundGateway源代碼位:

if (logger.isWarnEnabled()) { 
    logger.warn("The gateway cannot use a reply listener container with a specified destination(Name/Expression) " + 
       "without a 'correlation-key'; " + 
       "a container will NOT be used; " + 
       "to avoid this problem, set the 'correlation-key' attribute; " + 
       "some consumers, including the Spring Integration <jms:inbound-gateway/>, " + 
       "support the use of the value 'JMSCorrelationID' " + 
       "for this purpose. Alternatively, do not specify a reply destination " + 
       "and a temporary queue will be used for replies."); 
    } 

,有點後來在handleRequestMessage

if (this.replyContainer == null) { 
    jmsReply = this.sendAndReceiveWithoutContainer(requestMessage); 
} 

所以,你可以使用<int-jms:outbound-gateway>沒有reply-listener。 類似這樣的:

<int-jms:outbound-gateway request-destination="requestQueueA" 
           reply-destination="replyQueueB" 
           connection-factory="connectionFactory"/> 
+0

因此,設置回覆目標,「答覆偵聽器」將不會被創建?我的疑問是,臨時隊列既不會創建回覆監聽器。並設置它的答覆目的地將它添加到JMS頭,如果我有300隊列與另外300個答覆隊列配置是相當詳細的。 (事實上​​,JMS配置就是這樣的)。問候。 –

+0

是的,它依賴'consumerSession.createConsumer(replyTo,messageSelector);' –

+0

我將測試並檢查發生了什麼。韓國社交協會。 –