Call a server action asynchronously

Hi,


I have a process where i am calling different server actions. One of them should be called asynchronously, as it could be long running and other actions should not wait for it. 


I can not call it separately as it is based on input of another action with in same list.


I created a process as someone said that processes are being executed asynchronously and called  respective action on process start event. But it was executing synchronously.


Can anyone let me know how can we achieve the above scenario,

Hi Bilal,

What "process" do you have? Are we talking a Web App using BPT?

Also, I don't understand what you mean by "call it separately", and "within the same list" - what kind of list are you talking about?

EDIT: In this situation:

AutomaticActivity2 and 3 run in parallel, and start after AutomaticActivity1.

Hi, 

Have you tried to use a timer to run that action , not schedule the timer, and use the "wake" action generated automatically to launch the time every time you need it.

Hope this helps

Graça Peixoto

This will execute 3 actions at same time

Hello Bilal, 

As you noticed, you received 3 different answers that may not be the solution yet. This is because your question is not properly formulated. There is not enough context.

I would like to point you to this article on how to ask questions here in the form.
The idea is to help you get help faster, and for that to happen, it is necessary to make good questions. 

Hope it will be useful in the future.

Feel free to improve your question with more information in order to help others to understand your needs and problem. 

Cheers.

Hi Bilal Iqbal,


You can use a Timer or a BPT to execute flows asynchronously. In both options I would suggest some queue system.


You said you need inputs so I would suggest creating an Entity(it should also be your queue) that will have your inputs. 

If you choose the BPT option, you can just run it when a new record is created.

If you choose the Timer option, you will need a control on the Queue Entity to see if was already run for a record. You also need to have control on the Timer for:

  • how many records will it process per run?
  • timeout protecting mechanism.
  • re-running the timer to process the remaining records in the queue.
  • ...

You can choose to wake up the timer when a Queue record is created or just let it run in a schedule.


Keep in mind that instead of calling the asynchronous action together with the other two that you mention, you will just create a record in Queue entity. The BPT/Timer will call the server action that you want as asynchronous. 

Best Regards,

Jorge Cerveira


Hi every one,


Thanks for supporting me. I did not try above solutions yet but someone suggested that my question is not clear so i re-phrase my question:


We have a mobile application. User has option to transfer money but there is a daily limit on amount to be transferred per day. 

On UI, user select From / To Accounts and amounts and also daily limit is displayed. When user submit request, transaction request is submitted to a web service. Once it is successful done, then another service is called to update daily limit (deduct current transaction amount). So when user will open transfer screen again, limit will be updated.


Limit Update function should be called asynchronous so that as soon as first service call is successful then user will be displayed with success message and allowed further actions on UI.


I hope that i explained my scenario. 

Hi Bilal,

Thanks for the explanation, that helps a lot. First, I assume that the transaction request's data (i.e., things like account number, amount to deduct etc.) is stored in an Entity. This means that, for any type of asynchronous behaviour to work, all you need to do in the server call is to store the information sent by the mobile device, and return a "success" (most likely, you also would like to do some sanity checking).

Next, you can chose how to proceed. If a quick update of the user's daily limit is required, a BPT Process could be triggered by the creation of an Enitity Record. This BPT process can then call the other service for updating. Using a Timer here would be no good, especially if you need a quick update, and there are a lot of users updating at the same time.

Alternatively, if the update service is itself already asynchronous, in that it receives the data, then returns before actual processing, you don't need all of this, and can just call it from the Server Action or REST Method that is called by the Mobile App.

Yes Bilal, Thanks. 

I believe timer  solution works, but I have not explored mobile that deep enough. 

Graça


The timer solution doesn't work in this case, though it has little to do with Mobile. As Bilal stated, the Mobile App calls the Server (via a Server Action or a REST Method), so from then on, it's all Web.

Why doesn't it work? Timers are primarily used for batch processing. They typically run only once or twice a day, and churn away at a lot of data at once. In Bilal's case, there's not a lot of data, viz. a single deduction, and since it's about updating the daily limit, that deduction must be performed fast. Of course, the Service Action / REST Method could start a Timer, but there's several downsides: first, there's a limit to how many timers can run at the same time. Typically, this is three. So if more than three users perform an update, the deduction is queued, which may not be desirable. Secondly, Timers are relatively slow to start. It may take a while (typically 30s or so) for a Timer to get started. BPT processes are much faster to start, and there can be more running at the same time.