Qorus Integration Engine®  5.1.2_git
OMQ::UserApi::Workflow::QorusAsyncArrayStep Class Referenceabstract

The abstract class for asynchronous array steps. More...

Inheritance diagram for OMQ::UserApi::Workflow::QorusAsyncArrayStep:
OMQ::UserApi::Workflow::QorusAsyncStepBase OMQ::UserApi::Workflow::QorusStepBase

Public Member Methods

abstract public softlist< auto > array ()
 The array method returns the list of elements for the step. More...
 
abstract public nothing primary (auto array_arg)
 The primary step logic for the async step. More...
 
string validation (*string async_key, auto array_arg)
 Validation logic for the step. More...
 
nothing end (auto queue_data, auto array_arg)
 This method is run when the queue data bound to the asynchronous is updated and receives status OMQ::QS_Received. More...
 

Additional Inherited Members

- Static Public Member Methods inherited from OMQ::UserApi::Workflow::QorusAsyncStepBase
static public submitAsyncKey (string key)
 Binds the given key to the asynchronous step. More...
 
static public skipAsyncStep ()
 This method will skip the execution of an asynchronous step. More...
 

Detailed Description

The abstract class for asynchronous array steps.

An asynchronous step should be used any time a workflow action should be executed and it's not known in advance how long the action could take, or if the action should take a long period of time.

Example
# name: MyAsyncArrayStepClass
# version: 1.0
# desc: my async step class
%new-style
%require-types
%strict-types
%enable-all-warnings
class MyAsyncArrayStepClass inherits QorusAsyncArrayStep {
softlist<auto> array() {
# ... array logic
}
primary(auto array_arg) {
# ... primary step logic
}
string validation(*string key, auto array_arg) {
# call checkAction() to check in the target DB if the action has completed
if (checkAction(key)) {
return OMQ::StatComplete;
}
# call checkPending() to see if we retry or still wait
return checkPending(key) ? OMQ::StatAsyncWaiting : OMQ::StatRetry;
}
end(hash<auto> data, auto array_arg) {
# the error thrown here should be defined as a workflow error
if (data.status == "ERROR") {
throw "ASYNC-RECEIVE-ERROR";
} else {
log(LoggerLevel::INFO, "data status: %y", data.status);
}
}
bool checkAction(string key) {
# ... logic here
}
bool checkPending(string key) {
# ... logic here
}
}
# END
Note
Qorus step constructors do not take any arguments; see Step Constructors and Static Initialization for information about constructors and static class initialization.
See also
Asynchronous Steps and Array Step

Member Function Documentation

◆ array()

abstract public softlist<auto> OMQ::UserApi::Workflow::QorusAsyncArrayStep::array ( )
pure virtual

The array method returns the list of elements for the step.

Returns
The return value of the array method will determine how many times the step will execute, and on what data; null or a zero-length array means to skip the step entirely. Each element in this array indicates an array step element; each element will be passed as the argument to primary() and validation()
Note
this method must always return the same list in the same order in every call (for example if the step must be recovereed); use Workflow Dynamic Order Data to save the list to ensure that this method always returns the same list in the same order if necessary

◆ end()

nothing OMQ::UserApi::Workflow::QorusAsyncArrayStep::end ( auto  queue_data,
auto  array_arg 
)

This method is run when the queue data bound to the asynchronous is updated and receives status OMQ::QS_Received.

The job of this method is to determine if the asynchronously-received data is correct or not; if it is not correct, then the code should raise an error by calling wf_serror() or by throwing an appropriate exception. If no validation of the data is required, then the method body may be empty.

Parameters
queue_dataany data that was posted when the queue status got status OMQ::QS_Received
array_argthe array element for this step index as returned by the array method
Note
the implementation of the logic in this base class is empty; it must be overridden in child classes to react to the async queue data

◆ primary()

abstract public nothing OMQ::UserApi::Workflow::QorusAsyncArrayStep::primary ( auto  array_arg)
pure virtual

The primary step logic for the async step.

Parameters
array_argthe array element for this step index as returned by the array method

This code must call either submitAsyncKey() or skipAsyncStep() or an error will be raised.

If the step is not to be skipped, then the step nust start the asynchronous action and save a unique key for the action by calling the submitAsyncKey() workflow API method.

◆ validation()

string OMQ::UserApi::Workflow::QorusAsyncArrayStep::validation ( *string  async_key,
auto  array_arg 
)

Validation logic for the step.

This method must be overridden for steps that can only execute once; by default this method will return OMQ::StatRetry, meaning that the primary step logic will be repeated.

Parameters
async_keythe asynchronous key for the step, if bound, if not, this value will be NOTHING
array_argthe array element for this step index as returned by the array method
Returns
this must be one of the following step status constants:
  • StatComplete: do not run the primary step logic; mark the step as "COMPLETE" and continue. For asynchronous steps, the back-end logic (end()) will not be run in this case
  • StatError: do not run the primary step logic; mark the step as "ERROR" and stop running any further dependencies of this step
  • StatRetry: run the step logic again immediately. If the step is an asynchronous step with queue data with a OMQ::QS_Waiting status, the queue data will be deleted immediately before the step code is run again
  • StatAsyncWaiting: for asynchronous steps only, do not run the step code and keep the "ASYNC-WAITING" status. For non-asynchronous steps, raises an error and the return value is treated like OMQ::StatError
Note
if any other value than the above is returned, an error is raised and the return value is treated like OMQ::StatError
See also

The documentation for this class was generated from the following file:
OMQ::UserApi::log
deprecated log(softint lvl, softstring msg)
Writes the information passed to the workflow, service, job, or system log file depending on the call...