a9cd7750f4
CI / unit-test (push) Has been cancelled
CI / detect-changes (push) Has been cancelled
CI / build (push) Has been cancelled
Publish docs via GitHub Pages / Deploy docs (push) Has been cancelled
CI / test-harness (push) Has been cancelled
CI / generate-e2e-matrix (push) Has been cancelled
CI / e2e (push) Has been cancelled
CI / build-ui (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
UI v2 Integration CI / E2E (Integration) (push) Has been cancelled
UI v2 CI / Lint, Format & Test (push) Has been cancelled
UI v2 CI / E2E (Mocked) (push) Has been cancelled
128 lines
6.0 KiB
Markdown
128 lines
6.0 KiB
Markdown
---
|
||
description: "Create and update task definitions in Conductor to configure timeouts, retries, rate limits, and input templates for worker and system tasks."
|
||
---
|
||
|
||
# Creating / Updating Task Definitions
|
||
|
||
A [task definition](../../../documentation/configuration/taskdef.md) specifies a task’s general implementation details:
|
||
|
||
- Timeout policy
|
||
- Retry logic
|
||
- Rate limit and execution limit
|
||
- Input/output keys
|
||
- Input template
|
||
|
||
This definition applies to all instances of the task across workflows.
|
||
|
||
You can create task definitions using the Conductor UI or APIs for the following scenarios:
|
||
|
||
- **Worker tasks**—All Worker tasks (`SIMPLE`) must be registered to the Conductor server as a task definition before it can execute in a workflow.
|
||
- **System tasks**—System tasks don't require a task definition, but you can create one with the same name to customize retry, timeout, and rate limit behavior.
|
||
|
||
## Using Conductor UI
|
||
|
||
With the UI, you can create or update task definitions visually.
|
||
|
||
### Creating task definitions
|
||
|
||
**To create a task definition:**
|
||
|
||
1. In [**Executions** > **Tasks**](http://localhost:8080/taskDefs), select **+ New Task Definition**.
|
||
2. Configure the task definition JSON. Refer to [Task Definitions](../../../documentation/configuration/taskdef.md) for the full parameters.
|
||
3. Select **Save** > **Save**.
|
||
|
||
### Updating task definitions
|
||
|
||
**To update a task definition:**
|
||
|
||
1. In [**Executions** > **Tasks**](http://localhost:8080/taskDefs), select the task definition to be updated.
|
||
2. Modify the task definition JSON. Refer to [Task Definitions](../../../documentation/configuration/taskdef.md) for the full parameters.
|
||
3. Select **Save** > **Save**.
|
||
|
||
## Using the CLI
|
||
|
||
You can create task definitions using the Conductor CLI. Save your task definitions to a JSON file and run:
|
||
|
||
```bash
|
||
conductor task create tasks.json
|
||
```
|
||
|
||
The file should contain an array of task definitions. Refer to [Task Definitions](../../../documentation/configuration/taskdef.md) for a reference guide on the full parameters.
|
||
|
||
## Using APIs
|
||
|
||
Refer to [Task Definitions](../../../documentation/configuration/taskdef.md) for a reference guide on the full parameters.
|
||
|
||
### Creating task definitions
|
||
|
||
You can also create task definitions using the Create Task Definition API (`POST api/metadata/taskdefs`). The API accepts an array of task definitions, allowing you to create them in bulk.
|
||
|
||
??? note "Example using cURL"
|
||
```shell
|
||
curl '{{ server_host }}/api/metadata/taskdefs' \
|
||
-H 'accept: */*' \
|
||
-H 'content-type: application/json' \
|
||
--data-raw '[{"createdBy":"user","name":"sample_task_name_1","description":"This is a sample task for demo","responseTimeoutSeconds":10,"timeoutSeconds":30,"inputKeys":[],"outputKeys":[],"timeoutPolicy":"TIME_OUT_WF","retryCount":3,"retryLogic":"FIXED","retryDelaySeconds":5,"inputTemplate":{},"rateLimitPerFrequency":0,"rateLimitFrequencyInSeconds":1}]'
|
||
```
|
||
|
||
|
||
### Updating task definitions
|
||
|
||
You can update task definitions using the Update Task Definition API (`PUT api/metadata/taskdefs`). This API can only be used to update a single task definition at a time.
|
||
|
||
??? note "Example using cURL"
|
||
```shell
|
||
curl '{{ server_host }}/api/metadata/taskdefs' \
|
||
-X 'PUT' \
|
||
-H 'accept: */*' \
|
||
-H 'content-type: application/json' \
|
||
--data-raw '{"createdBy":"user","name":"sample_task_name_1","description":"This is a sample task for demo","responseTimeoutSeconds":10,"timeoutSeconds":30,"inputKeys":[],"outputKeys":[],"timeoutPolicy":"TIME_OUT_WF","retryCount":3,"retryLogic":"FIXED","retryDelaySeconds":5,"inputTemplate":{},"rateLimitPerFrequency":0,"rateLimitFrequencyInSeconds":1}'
|
||
```
|
||
|
||
|
||
## Using SDKs
|
||
|
||
Conductor offers client SDKs for popular languages which have library methods for making the API call. Refer to the SDK documentation to configure a client in your selected language to create or update task definitions.
|
||
|
||
Refer to [Task Definitions](../../../documentation/configuration/taskdef.md) for a reference guide on the full parameters.
|
||
|
||
### Creating task definitions - Example using JavaScript
|
||
|
||
In this example, the JavaScript Fetch API is used to create the task definition `sample_task_name_1`.
|
||
|
||
```javascript
|
||
fetch("{{ server_host }}/api/metadata/taskdefs", {
|
||
"headers": {
|
||
"accept": "*/*",
|
||
"content-type": "application/json",
|
||
},
|
||
"body": "[{\"createdBy\":\"user\",\"name\":\"sample_task_name_1\",\"description\":\"This is a sample task for demo\",\"responseTimeoutSeconds\":10,\"timeoutSeconds\":30,\"inputKeys\":[],\"outputKeys\":[],\"timeoutPolicy\":\"TIME_OUT_WF\",\"retryCount\":3,\"retryLogic\":\"FIXED\",\"retryDelaySeconds\":5,\"inputTemplate\":{},\"rateLimitPerFrequency\":0,\"rateLimitFrequencyInSeconds\":1}]",
|
||
"method": "POST"
|
||
});
|
||
```
|
||
|
||
|
||
### Updating task definitions - Example using JavaScript
|
||
|
||
In this example, the JavaScript Fetch API is used to update the task definition `sample_task_name_1`.
|
||
|
||
```javascript
|
||
fetch("{{ server_host }}/api/metadata/taskdefs", {
|
||
"headers": {
|
||
"accept": "*/*",
|
||
"content-type": "application/json",
|
||
},
|
||
"body": "{\"createdBy\":\"user\",\"name\":\"sample_task_name_1\",\"description\":\"This is a sample task for demo\",\"responseTimeoutSeconds\":10,\"timeoutSeconds\":30,\"inputKeys\":[],\"outputKeys\":[],\"timeoutPolicy\":\"TIME_OUT_WF\",\"retryCount\":3,\"retryLogic\":\"FIXED\",\"retryDelaySeconds\":5,\"inputTemplate\":{},\"rateLimitPerFrequency\":0,\"rateLimitFrequencyInSeconds\":1}",
|
||
"method": "PUT"
|
||
});
|
||
```
|
||
|
||
|
||
## Reusing tasks
|
||
|
||
Once a task is defined in Conductor, it can be reused numerous times:
|
||
|
||
- **In the same workflow** — use the same task with different task reference names.
|
||
- **Across workflows** — any workflow can reference any registered task definition.
|
||
|
||
When reusing tasks in a multi-tenant system, all work assigned to a task goes into the same queue by default. If a noisy neighbor causes polling delays, you can scale up the number of workers or use [task-to-domain](../../../documentation/api/taskdomains.md) to route task load into separate queues. |