2014-10-29 139 views
1

作爲一個整體,我仍然不熟悉Spring Integration和Spring框架,請耐心等待。我一直在看這個例子。觸發彈簧集成

https://github.com/benjaminwootton/spring-integration-examples/blob/master/target/classes/direct-channel-example.xml

https://github.com/benjaminwootton/spring-integration-examples/tree/master/src/main/java/examples/components

我不知道我該怎麼辦或觸發春季正是方法? 我正在嘗試爲我的REST服務使用直接通道進行循環法。我的REST服務使用消息並對其進行處理。

我知道使用直接渠道,Spring將循環遍歷訂閱者,但我不確定Spring如何實際觸發該方法。

謝謝任何​​幫助或建議。

回答

0

Spring Integration中的第一類公民MessageChannel,因此爲了允許消息(HTTP請求)在集成流程中傳播,我們應該將消息放置到某個<channel>

既然你說你是在REST服務,我假設你使用:

<int-http:inbound-gateway path="/path1,/path2" 
       request-channel="myChannel"/> 

這裏myChannel是在HTTP請求將轉換爲Spring集成Message之後被送到一個組成部分。

當然,MessageChannel是一個pipe,當我們把事情推到一邊時,真的應該有另一邊的東西來輪詢這個事情。在DirectChannel的情況下,它是一些subscriber。我們在這裏涉及二等公民 - MessageHandler

如果你使用像有東西<service-activator input-channel="myChannel" ref="foo" method="service">,調用堆棧可能看起來像:

DirectChannel#send -> UnicastingDispatcher#dispatch -> 
      ServiceActivatingHandler#handleMessage -> MethodInvokingMessageProcessor#processMessage -> 
       MessagingMethodInvokerHelper#process -> foo#service 

HTH