Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Spring IntegrationFlow Disallow Concurrent Execution

Is there a way we could instruct Spring IntegrationFlow DSL to avoid concurrent execution, for example – first run is still not completed however as per the Poller it is time for the second run? Similar to @DisallowConcurrentExecution we use in Spring Batch Quartz scheduler.

Thanks

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

To avoid concurrent execution from the polling channel adapter, you really must not use anything that could lead for parallelism. First: don’t use a TaskExecutor for the polling tasks. Second don’t use fixedRate and just fixedDelay. The second one behaves the way that it does schedule the next polling task only when the previous has finished. And if you don’t shift the work to other thread (see that TaskExecutor), anything is going to be performed on the same scheduled thread.

Technically what you are asking is there by default if you just use a fixedDelay for the poller and no more other options are configured.

Although you need to keep in mind that that the rest of your flow must be direct as well: no ExecutorChannel or QueueChannel in use!

Also see docs for conditional polling if you still cannot make your flow direct and blocking: https://docs.spring.io/spring-integration/docs/current/reference/html/core.html#conditional-pollers

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading