Reputation: 173
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
Upvotes: 0
Views: 372
Reputation: 121462
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
Upvotes: 1