Spring集成同步/异步消息流

时间:2015-12-16 16:44:29

标签: spring-integration

我是Spring集成的新手,我正在尝试建模一个流程,在这个流程中我通过HTTP获得同步请求和响应,但也是同一个流程的一部分 队列响应,后处理它,并有一个单独的进程消耗该响应。所以它从调用流的客户端的角度来看是同步的; 在响应放置在队列上的流中的异步。我在嵌入式Jetty服务器中托管gateway-context.xml和amqp-context.xml 并通过下面的HttpAmqpClientDemo从单独的流程发布。

我可以提交请求并收到回复,但是什么时候 我指定输出通道属性以传递给RabbitMQ,我不再通过配置的int-amqp接收响应:inbound-gateway 而是收到一个例外,说明“处理程序没有产生回复...... AmqpOutboundEndpoint#0”。

以下消息处理程序链配置为提供ServiceActivator注释方法的返回值(com.uscs.cdm.Response) 到输出通道“toRabbit”。

即使使用入站/出站通道 - 适配器对,我也会在预期下面的HttpAmqpClientDemo响应时收到HTTP 500状态码。 据我所知,当预期来自同一消息流的响应时,我应该使用入站/出站网关对。

我在这里做错了什么?另外,我是否应该使用入站通道适配器(下面的gateway-context.xml中的“fromRabbitReply”)来使用AMQP后处理的有效负载?

从下面的日志中,我确实看到'com.uscs.cdm.Response'是流程中的有效负载,但我无法用它做任何事情。

非常感谢您的帮助。

EDIT1 删除了不必要的配置,为通道使用了更合适的名称,并从服务器添加了完整的调试堆栈跟踪

HTTP的出站config.xml中

<int:gateway id="requestGateway2" 
             service-interface="org.springframework.integration.samples.http.RequestGateway"
             default-request-channel="requestChannel2"/>

<int:channel id="requestChannel2"/>

<int:object-to-json-transformer input-channel="requestChannel2" output-channel="outboundGatewayChannel" content-type="application/json" /> 
<int-http:outbound-gateway request-channel="outboundGatewayChannel" 
                           url="http://localhost:8280/http/receiveGateway2"
                           http-method="POST"
                           expected-response-type="com.uscs.cdm.Response"/>


<!-- From RabbitMQ To STDOUT -->

<int-amqp:inbound-channel-adapter channel="fromRabbitReply"
    queue-names="si.test.replyQueue" connection-factory="connectionFactory" />


<int:transformer input-channel="fromRabbitReply" output-channel="consoleOut" expression="'Reply received: ' + payload" />
<int-stream:stdout-channel-adapter id="consoleOut"
    append-newline="true" />    

<!-- Infrastructure -->

<rabbit:connection-factory id="connectionFactory" host="localhost" />

HttpAmqpClientDemo.java

    public class HttpAmqpClientDemo {

        private static Logger logger = Logger.getLogger(HttpClientDemo.class);

        public static void main(String[] args) {
            try {
                ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
                        "/META-INF/spring/integration/http-outbound-config.xml");
                RequestGateway requestGateway = context.getBean("requestGateway2", RequestGateway.class);
                Request request = new Request(123, "Some value");
                Response reply = requestGateway.echo(request);
                logger.info("\n\n++++++++++++ Replied with: " + reply.getSomeResponseText() + " ++++++++++++\n");
                Thread.sleep(5000);
            } catch (BeansException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

网关context.xml中

<bean id="jackson2JsonObjectMapper" class="org.springframework.integration.support.json.Jackson2JsonObjectMapper" /> 

<int:channel id="receiveChannel_2A"/>
<int:channel id="receiveChannel_2B"/>

<int-http:inbound-gateway request-channel="receiveChannel_2A"
                      path="/receiveGateway2"
                      supported-methods="POST"/>

<int:json-to-object-transformer input-channel="receiveChannel_2A" output-channel="receiveChannel_2B" 
    type="com.uscs.cdm.Request" object-mapper="jackson2JsonObjectMapper" /> 

<int:chain input-channel="receiveChannel_2B" output-channel="toRabbit">
    <int:header-filter header-names="content-type" />
    <int:service-activator ref="requestGateway" />

AMQP-context.xml中

<int:channel id="toRabbit"/>
<int:channel id="fromRabbitReply" />

<int-amqp:outbound-gateway
    request-channel="toRabbit" amqp-template="amqpTemplate" 
    exchange-name="si.test.exchange"
    routing-key="si.test.binding" />

<bean id="myServiceHandler" class="org.springframework.integration.samples.amqp.HandlerService"/>
<int:service-activator input-channel="fromRabbit"
    ref="myServiceHandler"
    method="handle"/>

<int-amqp:inbound-gateway request-channel="fromRabbit"
    queue-names="si.test.queue" connection-factory="connectionFactory" />

<int:channel id="fromRabbit">
    <int:interceptors>
        <int:wire-tap channel="loggingChannel" />
    </int:interceptors>
</int:channel>

<int:transformer input-channel="fromRabbit" output-channel="consoleOut" expression="'Received: ' + payload" />

<int-stream:stdout-channel-adapter id="consoleOut"
    append-newline="true" />

<int:logging-channel-adapter id="loggingChannel" log-full-message="true" logger-name="tapInbound"
    level="INFO" />

<!-- Infrastructure -->
<rabbit:connection-factory id="connectionFactory" host="localhost" />
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" />
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue name="si.test.queue" />
<rabbit:queue name="si.test.replyQueue" />

<rabbit:direct-exchange name="si.test.exchange">
    <rabbit:bindings>
        <rabbit:binding queue="si.test.queue" key="si.test.binding" />
        <rabbit:binding queue="si.test.replyQueue" key="si.test.reply.binding" />
    </rabbit:bindings>
</rabbit:direct-exchange>

来自服务器的堆栈跟踪:

        13:43:23.774 [qtp692680779-32 - /http/receiveGateway2] DEBUG o.s.i.h.i.HttpRequestHandlingMessagingGateway - failure occurred in gateway sendAndReceive: No reply produced by handler 'org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint#0', and its 'requiresReply' property is set to true.
        13:43:23.774 [qtp692680779-32 - /http/receiveGateway2] DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver - Resolving exception from handler [org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway#1]: org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint#0', and its 'requiresReply' property is set to true.
        13:43:23.774 [qtp692680779-32 - /http/receiveGateway2] DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway#1]: org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint#0', and its 'requiresReply' property is set to true.
        13:43:23.774 [qtp692680779-32 - /http/receiveGateway2] DEBUG o.s.web.servlet.DispatcherServlet - Could not complete request
        org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint#0', and its 'requiresReply' property is set to true.
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:109) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:231) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:154) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.MessageHandlerChain$ReplyForwardingMessageChannel.send(MessageHandlerChain.java:233) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:231) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:154) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:102) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:123) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:231) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:154) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:102) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:104) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:392) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:231) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:154) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:102) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:147) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:120) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:442) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:150) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:45) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:42) ~[spring-messaging-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:97) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:422) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:390) ~[spring-integration-core-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.actualDoHandleRequest(HttpRequestHandlingEndpointSupport.java:509) ~[spring-integration-http-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.http.inbound.HttpRequestHandlingEndpointSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:404) ~[spring-integration-http-4.2.1.RELEASE.jar:na]
            at org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:103) ~[spring-integration-http-4.2.1.RELEASE.jar:na]
            at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) ~[spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) [spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) [spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) [javax.servlet-api-3.1.0.jar:3.1.0]
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) [spring-webmvc-4.2.2.RELEASE.jar:4.2.2.RELEASE]
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar:3.1.0]
            at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:224) [websocket-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) [jetty-security-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [jetty-servlet-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.Server.handle(Server.java:499) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) [jetty-io-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106]
            at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [jetty-util-9.2.14.v20151106.jar:9.2.14.v20151106]
            at java.lang.Thread.run(Unknown Source) [na:1.7.0_67]
        13:43:23.775 [qtp692680779-32 - /http/receiveGateway2] DEBUG o.s.b.c.w.OrderedRequestContextFilter - Cleared thread-bound request context: Request(POST /http/receiveGateway2)@21c7fd13

1 个答案:

答案 0 :(得分:0)

<int-amqp:outbound-gateway>等待响应,但您的<int-amqp:inbound-gateway request-channel="fromRabbit">没有这样做,只是使用<int-stream:stdout-channel-adapter>打印到控制台,所以这是消息流的结束:没有任何回复只是因为没有一个组件这样做。

要对<int-amqp:outbound-gateway> / <int-amqp:inbound-gateway>对做出回复,您不必担心任何replyQueue,因为这些网关会关注已使用Temporary Queue的网关}。

从另一方面,如果您未在组件上指定replyChannel,则所有Spring Integration请求/回复组件都会将结果从请求消息标头发送到output(reply)-channel

因此,您应该拥有一些<int-stream:stdout-channel-adapter>或任何其他双向组件,而不是单向<service-activator>,而不是output-channel选项。一切都会有效,因为涉及TemporaryReplyChannel

请阅读Spring Integration Reference Manual中的更多内容。