Simultaneous Parallel Processing of Multiple AJAX Posts Required
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2015 10:08 AM
Goal: onload of TASK, call 3rd party API for 8 separate asset grid tables.
- Asynchronous AJAX calls are necessary so that the UI is not frozen.
- Parallel calls are required so that the data for each grid is returned as quickly as possible.
Issues:
- - GlideAjax object won't work, because even though it is asynchronous, it cannot operate in parallel when executing multiple GlideAjax objects at once.
- - I am unaware of any other type of SN provided Object that would enable Parallel execution of multiple Async posts. However, I suspect that there should be one available due to the fact that the Homepage dashboard reports load asynchronously in parallel.
- - Multiple direct Asynchronous Ajax calls to a custom REST Processor via a Client Script also only executes in serial, not parallel. This is likely due to a one transaction at a time per session limitation on ServiceNow side.
Screenshots of serialized processing of 4 multiple Ajax calls to REST processor via dedicated Web Workers for each:
(Started in Parallel)
(Processed in Serial)
Questions:
- - Can the same mechanism used to load the Homepage dashboards asynchronously in parallel be used to meet my goal? Can you provide me with any information/documentation on how I can use this approach to solve my problem?
- - Is it possible to get around the limitation of one transaction at a time so that I can use the multiple Ajax calls to the custom REST Processor as a solution?
Thanks!
Michael Moody Software Engineer |
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2015 01:12 PM
Hi Michael,
All client transactions are serialized per session. That is, you can add as many gadgets as you want to your homepage/dashboard, but the AJAX requests that they launch at the same time when you load the dashboards (as any other kind of request to the instance that involves processing by a semaphore) are responded one at a time by the instance. They are still said to be asynchronous meaning that the browser does not block on a single call until each request is responded.
Other thing is that the browser can make some processing until it finally presents data on each gadget, giving the feeling that some gadgets are *presenting* data "in parallel". But data is always retrieved from the instance in a serialized way.
Cheers,
Carlos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2021 07:50 AM
Hi Mike,
Looks like you seem to be the only one that stumbled onto this issue! I was just wondering if you ever solved it as I'm seeing this too and would like to over come it, but as fair as I can see there isn't really any clean way around it.
Did you find any sensible solutions that allow you to make multiple GlideAjax or XMLHttpRequest (using a scripted REST API) and run them in parallel on the server?
Thanks,
BBFD