[英]Spring Integration Error Channel Handling Broken when used with Spring Cloud Sleuth
我創建了一個演示項目: https : //github.com/imram/si-errorhandling-sleuth 。
我有一個問題,當我在Spring Integration Application中使用Spring Cloud Sleuth時,錯誤流將中斷,即,如果給出了響應超時,網關將無限停止/直到超時,然后它將null返回給網關的調用者。
如果沒有Sleuth依賴關系而執行相同的應用程序,則沒有問題。
如果我的SI設置有問題或已知問題,請有人提供幫助。 如果這是一個問題,那么有人可以建議解決方法嗎?
僅供參考,我確實想在我的微服務中使用Sleuth生成每筆交易的關聯ID,以實現可追溯性。
謝謝!!
偵探有問題了; 我在那里提出了一個問題 。
編輯
這是一種解決方法-有點俗氣,但有效...
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());
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.