java - 与Spring Cloud Sleuth一起使用时,Spring Integration错误 channel 处理中断

标签 java spring error-handling spring-integration spring-cloud-sleuth

我创建了一个演示项目:https://github.com/imram/si-errorhandling-sleuth

我遇到的问题是,当我在Spring Integration Application中使用Spring Cloud Sleuth时,错误流就会中断,即网关无限停止/直到给出响应超时的超时为止,然后它将null返回给网关的调用者。

如果没有Sleuth依赖关系而执行相同的应用程序,则没有问题。

如果我的SI设置有问题或已知问题,请有人提供帮助。如果这是一个问题,那么有人可以建议解决方法吗?

仅供引用,我确实想在我的微服务中使用Sleuth生成每笔交易的关联ID,以实现可追溯性。

谢谢!!

最佳答案

侦探有问题了;我有raised an issue there

编辑

这是一种解决方法-有点俗气,但有效...

public class SleuthWorkAroundInterceptor extends ChannelInterceptorAdapter {

    @Override
    public Message<?> preSend(Message<?> message, MessageChannel channel) {
        if (!(message instanceof ErrorMessage)) {
            return message;
        }
        MessagingException payload = (MessagingException) message.getPayload();
        Message<?> failedMessage = payload.getFailedMessage();
        failedMessage = MessageBuilder.fromMessage(failedMessage)
                .removeHeader(MessageHeaders.REPLY_CHANNEL)
                .removeHeader(MessageHeaders.ERROR_CHANNEL)
                .build();
        return new ErrorMessage(new MessagingException(failedMessage, payload), message.getHeaders());
    }

}


@Bean
public SmartInitializingSingleton ecInterceptorConfigurer(AbstractMessageChannel errorChannel) {
    return () -> errorChannel.addInterceptor(0, new SleuthWorkAroundInterceptor());
}

关于java - 与Spring Cloud Sleuth一起使用时,Spring Integration错误 channel 处理中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46971098/

相关文章:

java - 将 Spring Boot 应用程序部署到 Weblogic — Weblogic 尝试将我的主类作为 XML 资源加载,但失败

jquery - 如何在 jQuery 中处理 403 ajax 响应

react-native - Catch block 没有捕捉到我的自定义 react 钩子(Hook)中抛出的错误

java - 摩尔斯电码到英语

java - 将包含 Swing Panel 从一个 Container 移动到另一个 Container 后,OfficeBean 不会显示

spring - 如何绕过重置 session 的到期时间

java - Spring @Async 执行器

assembly - OAM汇编代码错误

java - spring integration中如何并行同步处理?

java - 匹配字符串第一次出现的位置