Christian
Christian

Reputation: 113

"Repeat until condition satisfied" in Spring Integration

Here's the flow in a nutshell:

inputChannel->transformer->firstOutboundAdapter->pollingOutboundAdapter

Synopsis: the inputChannel receives the incoming message, passes on to the transformer which in turn passes on transformed message onto firstOutboundAdapter. The latter calls a web service (proprietary...) to kick off a process that takes a while to complete. In order to find out what status the process is another web service needs to be called periodically to determine the status.

Question: How can I implement the pollingOutboundAdapter to query the web service periodically and only return when the correct response has been received? Here's the catch: I'd like to pop a message on a queue, process it and only return to the pollingOutboundAdapter when ready. I would like to avoid writing some kind of repeat while scenario and just use Spring Integration message handling if possible...

I hope I communicated clear enough :) Any constructive input greatly appreciated!

Upvotes: 1

Views: 503

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121272

Try to figure out a solution with the RequestHandlerRetryAdvice: http://docs.spring.io/spring-integration/docs/4.3.6.RELEASE/reference/html/messaging-endpoints-chapter.html#message-handler-advice-chain

You can throw an exception until some condition and retryTemplate will perform the same call until success.

Upvotes: 2

Related Questions