spring-integration

Spring Integration Flow with Quartz


Have a Spring Integration application consisting of multiple integration flows and altogether the application is deployed as a container in Kubernetes. The container is auto-scaled as per the load.

Among these multiple integration flows, one such flow retries failed records from DB and at any point of time only one instance of it should run (like the Quartz integration in Spring Batch).

How can this behavior be implemented in Spring Integration?


Solution

  • You can achieve that with a distributed lock: https://docs.spring.io/spring-integration/reference/distributed-locks.html. So, even if all your nodes would wait for a lock, only one of the would be able to process those polled records and so on. The rest nodes would be idle and ends their process quickly with empty polling result.

    Another pattern is to use a QueueChannel back by the DB MessageStore, and only one node would pull the record and process it. The next message in the queue might be processed by another node. If processing fails, the transaction will rollback and message comes back to the DB. See more info in docs: https://docs.spring.io/spring-integration/reference/message-store.html