简体   繁体   English

消息标头是 Spring 带有子流的集成流

[英]Message Headers is Spring Integration flow with subflows

There is below main Spring Integration flow that receives the request through HTTP, handle it using several subflows and then replies to the consumer.下面是主要的 Spring 集成流程,它通过 HTTP 接收请求,使用多个子流程处理它,然后回复消费者。 The problem is that when the flow enters the first subflow, it loses practically all its headers including reply channel.问题是当流进入第一个子流时,它几乎丢失了所有的头,包括回复通道。

I want to know to what point the headers from the request should reach?我想知道请求的标头应该达到什么程度? to the end of the flow(RESPONSE_CHANNEL)?到流的末尾(RESPONSE_CHANNEL)? And how to avoid losing headers after entering subflow?以及进入子流后如何避免丢包头?

@Bean
public IntegrationFlow exampleFlow() {
  return IntegrationFlows.from(
      Http.inboundGateway("/conversions/lower")
          .requestMapping(r -> r.methods(HttpMethod.POST)
          .mappedRequestHeaders("*") 
          .requestPayloadType(Foo.class)
          .replyChannel(RESPONSE_CHANNEL)
          .mappedResponseHeaders("*")
        )
      .transform(this:transforFoo)
      .channel(CHANNEL1)
      .handle(fooFlowConfiguration.flowHandler())
//several handlers in another subflow 
      .channel(RESPONSE_CHANNEL)
      .get();
}

I tried to enrich headers before the end of the flow, but it does not help And tried to add.mappedResponseHeaders("*")我试图在流程结束之前丰富标头,但它没有帮助并尝试添加.mappedResponseHeaders(“*”)

I think you just move to .channel(CHANNEL1).我想你只是移动到.channel(CHANNEL1).

And this part doesn't work:这部分不起作用:

handle(fooFlowConfiguration.flowHandler())
//several handlers in another subflow 
      .channel(RESPONSE_CHANNEL)

This one .replyChannel(RESPONSE_CHANNEL) I think for outbound gateway.我认为这一个.replyChannel(RESPONSE_CHANNEL)用于出站网关。

As I know the http gateway works in sync and just return last flow value.据我所知,http 网关同步工作,只返回最后一个流量值。 In your case its CHANNEL1 last step在你的情况下,它是 CHANNEL1 最后一步

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM