2
votes

i have a problem handling errors within a flow of spring integration. The flow works like this my entry point is a message driven channel adapter -> router -> filter -> transformer -> service activator -> Database. I've wrote my own error handler using a custom Message Listener Container, and it works as expected, but i need to save the original message into a database when i get an exception.

The problem is that, when i get an exception from the database, the error handle strategy recive a MessageHandleException, but the failedMessage in the exception is the message transformed, how can i get the original message in this case?

Thanks for your help.

1

1 Answers

2
votes

You should use header-enricher just after message driven channel adapter:

<int:header-enricher>
   <int:header name="originalPayload" expression="payload"/>
</int:header-enricher>

And use this header from that failedMessage in your own error handler.