Alexandre Juma
Alexandre Juma

Reputation: 3303

WSO2 Enterprise Integrator Sequence - Poll result after Asynchronous Call

Running WSO2 EI 6.2.0

I have a simple use case (Sequence) for WSO2 EI ESB:

  1. Extract some parameters from the original request
  2. Call an Async REST API
  3. Extract an Execution ID from the Async Call Payload
  4. Poll Loop another Sync API to check Execution Status based on Execution ID
  5. Halt polling when the Sync API says that the request is completed
  6. Extract some parameters from the last Sync Call
  7. Response

My problem lies on the Poll a Sync API until it returns some parameter saying that the previous Async execution is finnished.

Is there any WSO2 EI Sequence mediator for this sort of Poll Loop?

Upvotes: 0

Views: 354

Answers (1)

gusto2
gusto2

Reputation: 12075

The ESB mediations (sequences) are not really intended to keep the state and wait for anything. I'd believe it is even intention not having any sort "do/while" loop. We had a project requiring many polling steps and we used a process server to do so. So - with pure mediation it is very difficult to accomplish what are you asking for. Even you may check this one http://bsenduran.blogspot.com/2017/08/while-loop-in-wso2-esb.html

I will propose a few things you could do:

  • write a custom polling mediator (I really do not advice to do so)
  • use a process server (requires additional no-so-lightweight server)
  • use messaging with message processor (send a message to a queue, a message processor will poll, call and send the back to the queue or to response)

In all cases - if a client is waiting for a synchronous response, you need to finish the polling before the client times out. IMHO the best option return a message to a client (we are working on it) and avoid polling if possible..

Upvotes: 1

Related Questions