Make the response wait for sometime from scripted rest API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 10:06 PM
Hi
External interface is consuming our scripted rest API and posting a request.Our requirement is to wait for some time before sending response to external system,as have to wait for response from other external application and put that data in the API response and this may take sometime.
We have used gs.sleep before response.setBody but this is causing performance issue.
Any other best approach to achieve this is much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 10:32 PM
Hi Sadhana,
Asynchronous is the way to go!!.
You will have to let the requesting system know that you got the request - 200 response. dont let them wait till the time you call another system.
Once you get the information from the other system, You will have to post the information to requesting system. 2nd API.
Avoid creating waiting threads !!!. Dead lock
Thanks
Srinivas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 08:55 PM
Hi Srini,
The external system doesn't have a callback to post the response asynchronously.Is there any way we can implement this in synchronously ?
Thanks,
Sadhana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2017 10:35 PM
Hi,
You can use gs.eventQueueScheduled for scheduling the response asynchronously in a background event and process the response through a script action.
Notification Examples - ServiceNow Wiki
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2017 03:12 AM
is that possible to achieve in the same call , i meant synchronously ?
The custom scripted REST API executes the workflow and startFlow function returns the context id immediately whereas need to wait sometime to get the output one of the workflow activity to respond to client call.
IVR is the consumer and they dont have mechanism to provide the callback URL to get the response Asynchronously ?