Journey Manager (JM) The transaction engine for the platform. | System Manager / DevOps | All versions This feature is related to all versions.
Manager allows you to configure a collaboration job so their steps are executed asynchronously. This enables you to call external services, which return results asynchronously, from the collaboration job without blocking its execution thread. This process is similar to the Job Task Assign and Job Task Wait actions.
A typical asynchronous collaboration job consists of the following three steps.
The Async Invoke Wait step's job definition is shown below:
{
"name": "Async Invoke Wait",
"type": "",
"actions": [
{
"name": "AVT-4097 Job Action Invoke",
"type": "Job Action"
},
{
"name": "Wait For Callback",
"type": "Job Action Wait"
}
],
"routes": [
{ "name": "Default", "nextStep": "Application Completed" }
]
}
The Async Invoke Wait has two actions configured that allow the following job action state transitions:
Action Service | State Initial Run | State After Callback |
---|---|---|
Job Action | Invoked | Completed |
Job Action Wait | Pending | Completed |
The Job Action service is the Groovy service, AVT-4097 Job Action Invoke, is shown below.
def restCallOk = true
ActionResult actionResult = new ActionResult(Status.INVOKED)
// Call rest service
// hand rest failure
if(!restCallOk) {
actionResult = new ActionResult(Status.IN_PROGRESS)
// retry in 15 min (service Parameter)
}
return actionResult
The service does the following:
The external system may call back to a Groovy service REST endpoint, which can be generated by a new schedule task or triggered by a submission. In any case, it will get the job action key for the job action that called the external server, for example, the Job Action Invoke completeAction()
.
The following code is the test Callback implemented with Fluent API, which you can run from the Groovy console to see how collaboration job works.
import com.avoka.tm.svc.JobActionSvc
import com.avoka.tm.vo.Job
import com.avoka.tm.vo.JobAction
import com.avoka.tm.vo.JobStep
import com.avoka.tm.query.JobQuery
import com.avoka.tm.query.JobStepQuery
String jobRef = "QWKJMT7"
Job job = new JobQuery().setReferenceNumber(jobRef).firstValue()
JobStep jobStep = new JobStepQuery().setId(job.currentJobStepId).firstValue()
new JobActionSvc().setJobActionKey(jobStep.jobActions.first().jobActionKey).completeAction()
The callback does the following:
completeAction()
method.To check and change the asynchronous step status:
jobRef
with code from step 1 or 2.Click Close.
You can download the complete code example here.
{
"jobDetails": {
"name": "AVT-6611 Combined Wait Action",
"version": "19.5.0"
},
"jobGroups": [
],
"steps": [
{
"name": "Application Start",
"type": "start",
"actions": [
{
"name": "Accept Quote",
"type": "Job Form Start"
}
],
"routes": [
{ "name": "Default", "nextStep": "Async Invoke Wait" }
]
},
{
"name": "Async Invoke Wait",
"type": "",
"actions": [
{
"name": "Assign Review",
"type": "Job Task Assign",
"properties": [
{ "name": "Task Assign Groups", "value": "Job Reviewers" },
{ "name": "Task Form Code", "value": "$func.startFormCode()" },
{ "name": "Task Message", "value": "Please review the ${submission.formName} by ${formDataMap.firstName} ${formDataMap.lastName}." },
{ "name": "Task Review Previous Step", "value": "true" },
{ "name": "Task Subject", "value": "Review ${submission.formName} by ${submission.contactEmailAddress}." },
{ "name": "Task Type", "value": "Review" },
{ "name": "Task Enable Claiming", "value": "true" }
]
},
{
"name": "AVT-4097 Job Action Invoke",
"type": "Job Action"
},
{
"name": "Combined Wait Action",
"type": "Job Action Wait"
}
],
"routes": [
{ "name": "Default", "nextStep": "Application Completed" }
]
},
{
"name": "Application Completed",
"type": "endpoint"
}
]
}
The first step is Application Start, followed with the Async Invoke Wait step. The later has the Assign Review, AVT-4097 Job Action Invoke, and Combined Wait Action actions. The Combined Wait Action waits for both the Assign Review and AVT-4097 Job Action Invoke to finish before moving to the next, and final, step.
import com.avoka.fc.core.entity.JobAction
import com.avoka.fc.core.entity.JobStep
import com.avoka.fc.core.service.job.ActionContext
import com.avoka.fc.core.service.job.ActionResult
import com.avoka.fc.core.service.job.ActionResult.Status
import com.avoka.core.groovy.GroovyLogger as logger
/**
* Combined Wait Action
*
* This can be used to combine one or more Asynchronous Actions (Task Wait, Job Action) in the same Step.
* The wait does not do any routing based upon returned route name (like the Task Wait)
* It looks at the Action.status to see if the action has been completed.
* For Tasks it will do an additional check to see if the form is completed.
*
*/
JobAction jobAction = actionContext.getJobAction();
JobStep jobStep = jobAction.getJobStep();
for (JobAction action : jobStep.getOrderedJobActions()) {
if (action.id != jobAction.id && !action.isStatusCompleted()) {
return new ActionResult(ActionResult.Status.PENDING)
}
}
return new ActionResult(ActionResult.Status.COMPLETED)
The for
loop is the key of this service implementation.
This concludes the example.
Next, learn about one step anonymous review Collaboration Jobs.