Harji
Harji

Reputation: 85

Spring-Integration: Execute poller trigger by last message from previous poll

I have poller configuration like this:

<int:poller id="myPoller" default="true"  max-messages-per-poll="2" task-executor="executor"
                error-channel="errorChannel" receive-timeout="20000" trigger="dynamicTrigger">
    </int:poller>

But i need to trigger the poller with last time message from previous poll. For example of the flow:

If i have 4(A,B,C,D) Post rest the app will process 2(A,B) message first and then wait for the last response (either from A or B), afterward trigger the poll for next message (C,D).

How to achieve that condition ? Thx.

Upvotes: 1

Views: 382

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121262

Well, I suggest you to take a look into poller's <advice-chain>. With some custom MethodInterceptor you perform your decision logic and call your polling source stop(). When you have a desired response somewhere downstream you just perform start() of that endpoint again to let proceed with a new bunch of messages.

With enough big polling-interval you even don't need that <advice-chain> and just perform stop() in the downstream as well, via some state checking.

Also consider to use Control Bus for stop/start operations.

Upvotes: 1

Related Questions