cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to run code async in a ThingWorx service

oskarberntorp
13-Aquamarine

How to run code async in a ThingWorx service

Hi,

I am creating a service that fetches data from an external api with subsequent actions that needs to be run in a certain order. As an api call needs to finish, I wonder how to run code asyncroniously in a thingworx service?

 

I tried to write an async function, but I got the error in the image bellow, writing use 'esversion: 8' did not work.

 

Screenshot 2024-01-11 113657.png

ACCEPTED SOLUTION

Accepted Solutions

Will running the service itself as async will not work for you? From the service, you can either use property set event or event subscription to trigger other processes. If the other stuffs are not heavy/long you can probably put to same service.

View solution in original post

3 REPLIES 3

As of now you can't use it. TWX uses Rhino 1.7,11 (or so) and does not allow for the async feature. https://mozilla.github.io/rhino/compat/engines.html

 

Alternatives are Web hooks with the other system pushing the result into Thingworx or that you are polling regularly for the result with a request key.

PaiChung
22-Sapphire I
(To:Rocko)

From what you are saying, perhaps you can use the end of the API call to invoke an event/subscription to then start the next set of services.

Will running the service itself as async will not work for you? From the service, you can either use property set event or event subscription to trigger other processes. If the other stuffs are not heavy/long you can probably put to same service.

Announcements


Top Tags