Solved

Schedule a Task or Process Flow

  • 17 January 2022
  • 9 replies
  • 150 views

Userlevel 1
Badge +4

Is there a way to schedule a Task?

My goal is to query a rest webservice ( with HTTP connector) every minute.

icon

Best answer by Mark Jongeling 3 February 2022, 09:14

View original

9 replies

Userlevel 7
Badge +23

Hi,

Why would you need to run a Task in the System flow? Alternatively, you can use a Decision node in front of the HTTP connector. In this Decision node, you can utilize process procedure code to, for instance, calculate the URL and such.

If you need to run a task in front of the System flow, I recommend using the process action Execute system task (from 2021.3) or else use a Decision node to execute the Task stored procedure.

Your system flow would look something like this:

Start → Execute system task → HTTP connector → Stop (only 2021.3) or;

Start → Decision → HTTP connector → Stop

Userlevel 1
Badge +4

Hi Mark, i’m trying to test the Decision node; my goal is to fetch every 15 seconds a webservice and than insert some records on my database.  

Actually I have this flow:

 

The “machine_read_loop” Decision node Template  is something like this (it waits 15 seconds and than calls Insert_Production) :

WHILE 1=1
BEGIN
WAITFOR DELAY '00:00:15'
set @read_go=1

break

END;

set @Machine_Read_Loop_Machine_Running=-1 set @Machine_Read_Loop_execute_task_Insert_Production=1

 

 

The process flow works fine, every 15 seconds i have a new record. But when I start the process flow calling Open_Job_Flow and it start loop, the GUI is freezing and i must close the windows gui with task manager. 

 

I thought all the process flow worked in backgroud. Do I miss something? Am I doing something wrong?

The final step it should be: DECISION (loop) → HTTP Connector → Insert_Production Task

 

Userlevel 7
Badge +23

Hi,

I thought all the process flow worked in background.

That is not the case for the Windows GUI as the GUI executes all process flow actions itself. From beginning to end, the GUI will orchestrate all actions and will "freeze” the GUI during that as it is busy. It is also logical that it does that because the GUI is following the process flow and the user should not be taking any other actions during that.

That does also mean that during the execution of "WAITFOR DELAY '00:00:15'”, the user will also freeze for 15 seconds as the process flow is still running.

To counter this, you can make the process flow run as a system flow. The benefit is that a system flow does not have to start with a Task or by a user action by design. It can just start with an HTTP call and thereafter end. You can set the schedule in such a way that the system flow runs every 15 seconds for example. Although I don't know all the details of the process flow in the main topic, I do think that a system flow will be the solution.

 

Additionally, if it does need to be initiated by the user, you can create a table that contains the "Start system flow” information. As example I can tell how the Software Factory itself is using this. Once you want to run Generate definitions in the SF from 2021.3, you can press the execute button. This will insert a so-called job into the job table.

Indicium will execute a system flow every 5 seconds to see if Indicium needs to run a Generate definitions. It will use the Job table to determine that. If there's no job in the job table, then it will stop the system flow. If there is a Job in the job table, then it will "pick-up” that job and execute the system flow. Once it finishes, the job gets finished and the system flow will get back into the state of checking if it needs to run again or stop.

  

Userlevel 1
Badge +4

What about using subflows?

I might create a subflow that polls / fetch data every 15 seconds, and than start it from my main process flow. Do you think it will freeze the gui in this case, too? 

Userlevel 7
Badge +23

What about using subflows?

I might create a subflow that polls / fetch data every 15 seconds, and than start it from my main process flow. Do you think it will freeze the gui in this case, too? 

Sad to inform you that subflows do not work inside process flows in Windows GUI. Subflows can only be part of system flows.

Userlevel 1
Badge +4

Hi Mark, i’m testing system flow. I’ve scheduled it (as default)  from 1 AM to 12.59 every 5 seconds. Is there a way to force the first run?

 

 

Userlevel 7
Badge +23

Yes although it's not from within the IAM. You can send a POST request to Indicium to initiate the system flow. You can use a program such as Postman or Insomnia for this.

Userlevel 1
Badge +4

As you suggested i’ve found the solution:

 

  1. created a system flow and scheduled every 5 seconds in IAM, it check if it has to run a “subflow” 

 

 

  1. the subflow parse a webservice every 15 seconds and inserts data on my database

 

Thank you

Userlevel 7
Badge +23

Looks great! Awesome to see that a subflow resolves the problem :smile:  

Reply