In my Integration Flow I change from standard flow to an error flow in some error condition, stopping the standardStateEntryPoint
and starting the errorStateEntryPoint
via sending the start/stop command messages to the Control Channel
.
The errorStateEntryPoint
is this:
@Bean
public IntegrationFlow errorStateEntryPoint() {
return IntegrationFlows.from(
() -> new GenericMessage<String>(""),
e -> e.poller(p -> p.fixedDelay(ERROR_STATE_POLLING))
.id("errorStateSourcePollingChannelAdapter")
.autoStartup(false))
.channel("httpOutRequest")
.get();
}
It has a Poller
with a fixed delay of 5_000 ms. The recognized lifecycle when started is
send -> wait -> send -> wait etc.
Is it possible to have the inverse lifecycle, starting with the delay?
wait -> send -> wait -> send etc.
What I've found out:
You might set the initialDelay of the poller. If your poller has a period of 5.000 milliseconds without an initial delay, it is working this way:
send -> wait -> send -> wait etc.
If you set the same 5.000 milliseconds as initial delay, it is working exactly as required:
wait -> send -> wait -> send etc.
The initial delay is the second argument setting p.fixedDelay(...)
. Then the errorStateEntryPoint
polling channel adapter should be this:
@Bean
public IntegrationFlow errorStateEntryPoint() {
return IntegrationFlows.from(
() -> new GenericMessage<String>(""),
e -> e.poller(p -> p.fixedDelay(ERROR_STATE_POLLING, ERROR_STATE_POLLING))
.id("errorStateSourcePollingChannelAdapter")
.autoStartup(false))
.channel("httpOutRequest")
.get();
}
That's it.