【问题标题】:Spring Integration WebFlux inboundGateway replyChannel for error responseSpring Integration WebFlux inboundGateway replyChannel 用于错误响应
【发布时间】:2023-01-14 01:11:39
【问题描述】:

尝试使用 replyChannelWebFlux.inboundGateway 发送错误响应,但是没有从 ErrorFlow 发送响应,客户端继续等待响应。请建议。

return IntegrationFlows.from(WebFlux.inboundGateway("/some/uri")
                                    .requestMapping(m -> m.methods(POST))
                                    .requestPayloadType(SomeObject.class)
                                    .replyChannel(webReplyChannel)
                                    .errorChannel(appErrorChannel))


@Bean
public IntegrationFlow appErrorFlow() {

    return IntegrationFlows.from(appErrorChannel())
                        .transform(m -> "Error Response")
                        .channel(webReplyChannel)
                        .get();

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    这是已知的框架限制:https://github.com/spring-projects/spring-integration/issues/3984

    所以,现在你必须这样做:

    .transform(errorMessage -> MessageBuilder.withPayload("Error Response")
                    .copyHeaders(((MessagingException) errorMessage.getPayload()).getFailedMessage().getHeaders())
                    .build())
    

    只有那些 getFailedMessage().getHeaders() 包含各自的 replyChannelerrorChannel 标头。

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 1970-01-01
      • 2014-03-02
      • 2016-03-30
      • 2019-03-11
      • 2021-05-02
      相关资源
      最近更新 更多