By participating in the Advent calendar as an IT member of the company that changed jobs, I will post an article on Qiita for the first time! Since I changed jobs, I have been developing apps at Outsystems. I would like to share what I couldn't find the answer in the process of development.
This time, I will introduce how to implement asynchronous processing in Outsystems.
I will post for the first time, so I will introduce myself. Previously, I worked for about 7 years as an SE who is resident in various projects with about 30 SIers. At that time, I was developing in Java and C #, and also doing upstream processes such as requirement definition and design. From there, I changed jobs to a foreign-affiliated human resources company and became an in-house SE. Currently, Outsystems mainly develops apps for improving internal business efficiency.
--What is asynchronous processing? --Implementation method in client processing --Implementation method in server processing
What is asynchronous processing in the first place? I will explain it for those who say. I thought, but there was an article that explained it, so please refer to this. https://qiita.com/kiyodori/items/da434d169755cbb20447
For example, if you press a button on a web page and it takes a long time to go around the screen Usability is not good, so Processing that does not have to wait for the processing result will run asynchronously!
In Java, new a class that inherits Thread or a class that implements Runnable It seems to be realized by calling the start method, I couldn't find out how to achieve it with Outsystems, so I wanted to share it.
Let's go to the main subject!
What the image above is doing is Check the battery status of your smartphone or tablet and send an alert email when the battery is low I am creating a client action called NotifyBatteryStatus I'm calling it with setTimeout.
setTimeout($actions.NotifyBatteryStatus($parameters.Level, $parameters.IsPlugged), 0);
The first argument of setTimeout is the action (with argument) that you want to process asynchronously.
The second argument is how many milliseconds to execute. This time I want to execute it immediately, so I set it to 0.
Since sending an email has no choice but to call a server action, it takes time to process it via the network. I didn't have to look at the processing result, so I am trying to execute it asynchronously including the part that determines whether to send an email.
Timer is a batch process that starts schedule or executes manually, right? I'm feeling. You can call that Timer from a server action.
Like this You can call the Timer process by dragging and dropping Wake ~ under the Timer into the server action. So, it works asynchronously with the server action you are performing. When you call Wake ~, it will not be executed immediately, but will be executed after a few seconds.
However, the difficulty with asynchronous processing in Timer is that parameters cannot be passed. The next solution is to solve it.
Have you ever used Process? I wasn't .. I felt like I could use it like this.
You can call Launch ~ of Process from the server action and specify the argument. Entity is impossible, but BasicType such as Text and Integer and EntityIdentifier can be used as arguments. So pass the EntityIdentifier as an argument and It is possible to get data from Entity and process it in Process.
That's why I introduced how to implement asynchronous processing in Outsystems. Recently, Saas publishes various APIs, but it takes time to call them with REST or SOAP, so it takes time. I think it's common to call such processes asynchronously, so I hope you can refer to it!