What is the best way to make multiple call outs to compose a response?

Not applicable

I have a requirement to make multiple calls to the same API (with each call sending a different parameter payload). I want to concatenate the results from each call and return a single response to by client.

I had a look at using the ServiceCallout policy. The problem with this approach is I need one instance of the policy for each call out I make and one accompanying assign message policy to construct the request too. This is a very hard coded and verbose approach. Is there anyway to repeatedly call a policy programatically with variables?

Im assuming not... so my second approach I am trying is to use a Javascript policy and the httpClient to do the requests and compose the response. Ive written the script to do the call outs and that works ok. The requests are sent asynchronously and im using waitForComplete() to wait for them all to return before returning the response. And here is the problem: - sometimes the responses take some time to return and so it trips the JS policies 'runtime limit'. I think I can increase this limit, but I wonder if there is perhaps a better way to be doing this?

Solved Solved
0 5 1,186
1 ACCEPTED SOLUTION

@JamesSBuchanan , I prefer using a Node.JS target to do this. A Nodejs target is not subject to the timeLimit, as is the JS . policy. You can make parallel calls & send the mashup response back quickly. Have you explored the Node.JS option in Edge ?

View solution in original post

5 REPLIES 5

@JamesSBuchanan , I prefer using a Node.JS target to do this. A Nodejs target is not subject to the timeLimit, as is the JS . policy. You can make parallel calls & send the mashup response back quickly. Have you explored the Node.JS option in Edge ?

Would node not suffer from the same runtime timeout issue as the javascript policy?

@JamesSBuchanan , Nope. The timeout is specific to JS Policy.

Not applicable

@Anil Sagar @ Google - is there any example available explaining how to use NodeJs target for this kind of requirement?

Please ask a new question rather than posting a new question as an answer to a 18-month old question.

7778-ask-a-question.png