Closed kymr closed 6 years ago
Task domains helps support task development.
The idea is same “task definition” can be implemented in different “domains”.
A domain is some arbitrary name that the developer controls.
So when the workflow is started, the caller can specify, out of all the tasks in the workflow, which tasks need to run in a specific domain, this domain is then used to poll for task on the client side to execute it.
As an example if a workflow (WF1) has 3 tasks T1, T2, T3.
The workflow is deployed and working fine, which means there are T2 workers polling and executing.
If you modify T2 and run it locally there is no guarantee that your modified T2 worker will get the task that you are looking for as it coming from the general T2 queue.
“Task Domain” feature solves this problem by splitting the T2 queue by domains, so when the app polls for task T2 in a specific domain, it get the correct task.
When starting a workflow multiple domains can be specified as a fall backs
for example "domain1,domain2".
Conductor keeps track of last polling time for each task
so in this case it checks if the there are any active workers for "domain1" then the task is put in "domain1"
if not then the same check is done for the next domain in sequence "domain2" and so on.
If no workers are active then the task is schedule with no domain (default behavior).
Note that this "fall back" type domain strings can only be used when starting the workflow, when polling from the client only one domain is used.
conductor.worker.T2.domain=mydomain //Task T2 needs to poll for domain "mydomain"
GET /tasks/poll/batch/T2?workerid=myworker&domain=mydomain GET /tasks/poll/T2?workerid=myworker&domain=mydomain
Map<String, Object> input = new HashMap<>();
input.put("wf_input1", "one”);
Map<String, String> taskToDomain = new HashMap<>();
taskToDomain.put("T2", "mydomain");
// Other options ...
// taskToDomain.put("*", "mydomain") will put all tasks in mydomain
// taskToDomain.put("T2", "mydomain,fallbackDomain") If mydomain has no active workers
// for T2 then will be put in fallbackDomain. Same can be used with "*" too.
StartWorkflowRequest swr = new StartWorkflowRequest();
swr.withName(“myWorkflow”)
.withCorrelationId(“corr1”)
.withVersion(1)
.withInput(input)
.withTaskToDomain(taskToDomain);
wfclient.startWorkflow(swr);
{
"name": "myWorkflow",
"version": 1,
"correlatonId": "corr1"
"input": {
"wf_input1": "one"
},
"taskToDomain": {
"T2": "mydomain"
}
}
Link