Reputation: 3122
I need to adjust all error messages going back to the caller of my integration flows so that I do not leak information, no matter if they are thrown as exception or handled as asynchronous errors. I'd like to avoid defining a custom error channel on every message handler. I have tried to attach a transformer to the default error channel without success:
@Bean
IntegrationFlow errorFlow() {
return IntegrationFlows.from("errorChannel")
.transform("{'status': 500, 'error': 'Internal Server Error'}")
.get();
}
Is there a central point where I can transform all outgoing error messages?
Upvotes: 0
Views: 53
Reputation: 121262
According to your logic, it looks like you deal with REST - request/reply. So, you need to return a reply to request point. This is available via replyChannel
header of the request message. Such an information you can access in a MessagingException.failedMessage
property of the payload
in the ErrorMessage
.
Summarizing all of that your .transform()
must expect MessagingException
as a payload and produce output message with copying headers from that failedMessage
. This way the message will be sent to the reply channel of the HTTP Inbound Gateway request message.
Upvotes: 1