How to wrap header information in errorChannel?

In my application my gateway gets the request id in the header, whenever an error occurs, the error channel gets an exception. But it seems that errorChannel is not taking headers from the gateway.

Is it possible to carry header information to the error channel?

Example example: sysout in sampleErrorChannel does not have the header that I passed.


source to share

1 answer

Error channel message ErrorMessage

, it has a payload MessagingException

that has two properties: cause

(exception) and failedMessage


This way you can access unmanaged message headers.

eg. payload.failedMessage.headers['foo']

when using SpEL.

If you are using POJO service activator in error stream you can use

public void failure(MessagingException failure) {
    MyHeader mh = failure.getFailedMessage().getHeader("mh");




All Articles