2014-10-29 146 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