How to Extent the time to get the response from the target to make service callout request.

Not applicable

Hi ,

I use service callout policy to make an another request based on the target response.Target is responding with correct information after that I use AssignMessage policy set the request headers , payload and method to make a request to service callout policy which has service url set in the policy.

when the response is being sent from the Target url,based on that the serive callout should redirect to another service url.But the url which was set in the Assignmessage to fetch some information is returing the 404 Resource not found error.Due to that Service callout is failing and it is returing 500 error message.

What I found from the Target is that when we send the request from application the data at backend is taking time to reflect that why we are not able to make an another service callout request because the request for service callout is depends on the response from the url which is set in the Assign message policy.

To wait till the response receives from target I would like to introduce the time delay in the response from the url which is used in Assign Message policy.

So to achive this can I use javascript policy here??is so please help me in code.

or I can just increase the timelimit in the service callout policy would work??

Kindly suggest me here.

Thanks in Adavance.

0 5 1,061
5 REPLIES 5

Hi @sumiya - Would the <Timeout> element on the Service Callout policy meet your needs?

http://docs.apigee.com/api-services/reference/service-callout-policy#timeout

Hi Jones,

I have tried the service callout policy timeout element ,but that doesn't help to meet my requirment.

Ah, okay. I read too quickly, @sumiya. Apologies. Your Service Callout is in the response, and it depends on a successful response from the main target in order to set the Service Callout URL.

Have you tried setting/increasing the timeout on your TargetEndpoint? See http://docs.apigee.com/api-services/reference/endpoint-properties-reference#targetendpointtransportp....

Hi Sumiya

I hope you already have found the answer for this. However, for the benefit of those having similar problem statement and who are looking for this solution, can follow these steps:

  • Create a new JS Callout policy. Enter the JS Code as shown below.
  • Attach it to the flow (between policy, possibly service callout policy), wherever you want to introduce delay. Below code example introduces 5 seconds of delay.
function delay(time) {
    var d1 = new Date();
    var d2 = new Date();

    while (d2.valueOf() < d1.valueOf() + time) {
      d2 = new Date();
    }
  }
  delay(5000)

Regards

Sajan Mathew

cbmohit
Participant I

Great solution by @mathewsajan14. Thanks.
while trying I also noticed that we need to update the timeLimit in JS policy as well if we need to delay it for more than 200ms, by default its value is 200(ms).