0
votes

I have a transactional poller periodically polling messages from a jdbc-backed queue-channel.

I have 2 goals:
1) prevent message loss from my source in case the process dies in the middle of processing a message.
2) prevent a single misformatted message from bringing down the whole process by discarding the related exception to the error channel (and moving on to the next message)

My Question:
How can I setup (ideally through dsl) my transactional poller so that it discards a faulty message to the error channel without rolling back the transaction ?
(so as to prevent an infinite loop where the same message is replayed again and again).

Thank you very much in advance for your feedback and your expertise.

Best Regards

1

1 Answers

2
votes

The current architecture (and I doubt we will change it) is based on the fact that we sent to the errorChannel from poller already after transaction rollback. This way we cover not only the problem with your message, but possible failure during commit. Therefore any exceptions withing the poll task are handled with the same errorChannel.

Since such an errorChannel approach doesn't fit your requirements because the wrong message is going to be rolled back to the DB for the next poll, I would suggest you to consider to use an ExpressionEvaluatingRequestHandlerAdvice downstream around some minimal service, where you definitely fail with a wrong message. This way you can configure an appropriate failureChannel and send error message over there leave the whole process untouched and, therefore, committed properly in the end.

See more info in the Docs: https://docs.spring.io/spring-integration/docs/current/reference/html/#message-handler-advice-chain