Task domains help 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 for the domains provided:
NO_DOMAINis provided as last token in list of domains, then no domain is set.
- Else, task will be added to last inactive domain in list of domains, hoping that workers would soon be available for that domain.
* token can be used to apply domains for all tasks. This can be overridden by providing task specific mappings along with
For example, the below configuration:
"some_task_y": "someDomain, NO_DOMAIN",
"some_task_z": "someInactiveDomain1, someInactiveDomain2"
some_task_xin default queue (no domain).
someDomaindomain, if available or in default otherwise.
someInactiveDomain2, even though workers are not available yet.
- and puts all other tasks in
mydomain(even if workers are not available).
How to use Task Domains
Change the poll call
The poll call must now specify the domain.
If you are using the java client then a simple property change will force TaskRunnerConfigurer to pass the domain to the poller.
conductor.worker.T2.domain=mydomain //Task T2 needs to poll for domain "mydomain"
Change the start workflow call
When starting the workflow, make sure the task to domain mapping is passes
Map<String, Object> input = new HashMap<>();
Map<String, String> taskToDomain = new HashMap<>();
// Other options ...
// taskToDomain.put("*", "mydomain, NO_DOMAIN")
// taskToDomain.put("T2", "mydomain, fallbackDomain1, fallbackDomain2")
StartWorkflowRequest swr = new StartWorkflowRequest();
"some_task_y": "someDomain, NO_DOMAIN"