0

I have a demo project created: https://github.com/imram/si-errorhandling-sleuth.

I am having issue that when I use Spring Cloud Sleuth in my Spring Integration Application then Error Flow gets broken, i.e. gateway halts infinitely/ until timeouts if reply timeouts is given and then it returns null to invoker of the gateway.

If same application is executed without Sleuth Dependency, there is no issue.

Could someone please assist if there is something wrong in my SI setting or its known issue. If it is an issue then could someone please suggest workaround?

FYI, I do want to use Sleuth for the Correlation Id generation per transaction b/w my micro services for traceability purpose.

Thanks!!

Ram
  • 117
  • 1
  • 2
  • 8

1 Answers1

0

It's a problem with Sleuth; I have raised an issue there.

EDIT

Here's a workaround - a bit cheesy but it works...

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());
    }

}

and

@Bean
public SmartInitializingSingleton ecInterceptorConfigurer(AbstractMessageChannel errorChannel) {
    return () -> errorChannel.addInterceptor(0, new SleuthWorkAroundInterceptor());
}
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Thank you so much Gary. Your alternative did work. Also, before I got this solution, I was just turning off Sleuth for Integration temporarily using spring.sleuth.integration.enabled with value false.. – Ram Oct 27 '17 at 21:38
  • Thanks again for opening the defect as well!! – Ram Oct 27 '17 at 21:38