Skip to main content

Process queue

Introduction to Process queue

The Thinkwise Process queue is available for download from the Thinkstore. It offers an asynchronous queue that controls the execution of processes, so you no longer need to use database triggers. The architecture allows for seamless handling of subflows. This means you can invoke processes that integrate web connectors, application connectors, and other advanced functionalities. All of this is possible without affecting the integrity or performance of the database.

The Process queue is especially useful for asynchronous background processes, such as:

  • Generating (management) data.
  • Sending data to external systems.
  • Processing uploaded files.

Architecture

The Process queue contains three core tabels in its model:

  • sub_flow_queue - acts as the primary table, where each record is managed on a first-in, first-out basis.
  • sub_flow_queue_execution - records the execution details of each queue item, providing a clear log of all sub-flow actions performed.
  • sub_flow_queue_setting - configures essential rules for each process queue-enabled sub-flow. Currently, this table mainly determines the maximum number of concurrent executions allowed per sub-flow, ensuring optimized and controlled processing throughout the system.

By default, a sub-flow can not be executed by the Process queue. To enable a system flow for the Process queue, add the tag process_queue_enabled to the sub-flow in the menu Processes > Subflows > tab Process flow tags

You must run the Creation process to use the subflow in the Process queue. After doing so, the subflow becomes visible in the sub_flow_queue_setting table.

Process queue tables

sub_flow_queue

ColumnDatatypeDescription
sub_flow_queue_idbigint identity, PKPrimary key of the queue item.
sub_flow_queue_statustinyint1 – new
2 – processing
3 – processed
90 – error
scheduled_execution_date_timedatetime2When this is filled in, the queue item is only executed after this datetime.
start_date_timedatetime2Start date and time of the queue item.
end_date_timedatetime2End date and time of the queue item.
sub_flow_idvarchar(100)The sub_flow_id used in the Software Factory for the sub flow to execute.
sub_flow_parametersnvarchar(max)Parameters to pass to the sub flow, which can be used in its actions.
sub_flow_status_codeintOutput status code of the executed subflow.

sub_flow_queue_execution

ColumnDatatypeDescription
sub_flow_queue_idbigintCorresponding sub_flow_queue_id (PK).
sub_flow_queue_execution_idbigintIdentity, PK.
process_action_typevarchar(256)Type of the process action (for example, decision, generate_report).
process_action_namevarchar(256)Name of the action as defined in the Software Factory.
start_date_timedatetime2Start date and time of the process action.
end_date_timedatetime2End date and time of the process action.

sub_flow_setting

ColumnDatatypeDescription
sub_flow_idvarchar(100)Sub flow ID from the Software Factory.
max_concurrent_queue_executionIntMandatory. Default value is 1.

Process flow

In this solution, we use a scheduled process flow to execute subflows in the queue. This process flow consists of two decisions and a single process action: Execute subflow. For each subflow that has process queue enabled in the Software Factory, a separate process action is added to the process flow. For example, in the image below, the subflow is named test_sub_flow, resulting in the process action being named Execute subflow test_sub_flow.

The decision Read the sub_flow_queue table selects the following item from the sub_flow_queue table to execute. The selection depends on the maximum concurrent executions and the scheduled start date and time. The order is also determined by the sub_flow_queue_id.

Lastly, the decision Update the sub_flow_queue table updates the status of the sub_flow_queue item.

Process flow for executing subflows in the process queue

Retention

A scheduled system flow will run at 1:00 AM UTC to clean up the history of the process queue. By default, items older than 90 days will be deleted. You can change the default in the system flow sub_flow_queue_retention by changing the process flow parameter retention_in_days.


Was this article helpful?