Search code examples
spring-integrationspring-integration-dsl

Spring integration - How to make message survive in jdbc message store in case of an error or/and shut down in consuming handler


I have a flow that stores messages into jdbc message store:

...
.channel { c -> c.queue(jdbcChannelMessageStore, "persist") }
.handle(MessageHandler { 
                        Thread.sleep(3000); 
                        throw RuntimeException() 
} ) { e -> e.poller { it.fixedDelay(1000)} }

How to make sure that message is not deleted until hanler succesfully finishes?


Solution

  • Make the poller .transactional() so that the downstream flow runs in a transaction; the removal won't be committed until the flow ends (or hands off to another thread).