Async Connector Requests inside a serverside Business Object
-
Christopher Steinbach3 years ago #26374
Hi,
I’m looking for a way to do async connector requests inside a serverside BO.
I have a use case where I have to process a row of time consuming connector requests combined with a CryptoJS data decryption. I thought it would be best to wrap this in a single BO-Call instead of doing multiple request from the client, which will cause more overhead and will eventually instability problems.
But theres no async Connector API nor a JS language support for doing this.
Is there a hidden utility api to make those connector calls async and wait for them all to finish before returning the result of the BO? Or do I really have to solve this client side?
Thank you for your help.
DanHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)3 years ago #26385::Hey,
maybe i got your use case wrong so please correct me if necessary.
You want to trigger a few connector calls and use the result of each of those to combine it and afterwards use CryptoJS.
When all this is done the result should be returned to your client application.You can use a server side business object to achieve this. Implement the needed connector calls inside the business object by using the Business Object API and save the results into variables, combine everything and add your CryptoJS logic.
The call of the server side business object from the client is asynchronous, the logic inside the business object is synchronous.
The BO will return the result only after every connector call is finished and the rest of the logic is executed.Hope that helps you
Christopher Steinbach3 years ago #26386::Hi Dan,
as you said, the logic inside a business object is synchronous only.
In my example I want to load 10 or more encrypted files via REST-Connector call and decrypt each file as they arrive. In a synchronous world this is very time consuming by doing this one by one.
My first idea to solve this was to use JS-Promises. But the ES5 doesn’t support JS-Promises. Then I thought there might be an alternative Connector Call to get a promise instead the result. Like certain JQuery-based Libs does in good old ES5 times. But this would not work either because this would require to have some kind of callback function to resolve the BO-Call itself after all promises are resolved.
It seems that have to solve this client side.
Armin WinklerHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)3 years ago #26390::Hi Christopher,
you are right, as of now this is a typical use case that has to be implemented inside of a client-side business object function (or a script activity, if you prefer to use that). Unfortunately server-side business objects (SBO) don’t support JavaScript Promises yet, but this is subject to change in a future Simplifier release where we plan to update the JavaScript engine of SBOs to make ECMAScript features of versions higher than 5.1 accessible. Please keep a close look on our changelog for that matter.
Regards,
Armin
You must be logged in to reply to this topic.