Upgrading a single-triggered task to be multi-triggered
Upgrade your duplicated single-triggered tasks to one single task with multiple triggers.You may have duplicated a task for each of the triggers you need to use for this task. You do not need to do this anymore. You can now directly define these triggers for a schedule and apply that schedule to this task.
Before you begin
- Generate an access token:
- For users, generate a personal access token. For further information, see Generating a Personal Access Token.
- For service accounts, generate a service account token. For further information about how to generate a service account token, see Generating a service account token. Once generated, a service account token expires after 30 minutes. If it expires, generate a new token using the POST method at the endpoint
https://api.{env}.cloud.talend.com/security/oauth/token
.
-
You must know the ID of the task you need to associate the schedule.
In Talend Cloud Management Console, this ID is displayed on the dedicated page of this task. For example:
Or you can obtain task IDs via the following API request:
method: GET endpoint: https://api.<env>.cloud.talend.com/processing/executables/tasks headers: { "Content-Type": "application/json", "Authorization": "Bearer <your_personal_or_service_account_access_token>" } query parameters: { "workspaceId": "id_of_the_workspace_of_the_task_to_be_updated" }
-
Ensure that the user or the service account to be used have the
TMC_OPERATOR
role and theEXECUTOR
permission for the workspace to which the task to be updated belongs.
Procedure
-
Get existing triggers of the task instances that you need to upgrade to be one single multi-triggered task. To do this, issue the following API request for each of the task instances.
method: GET endpoint: https://api.<env>.cloud.talend.com/orchestration/executables/tasks/<taskId>/run-config headers: { "Content-Type": "application/json", "Authorization": "Bearer <your_personal_or_service_account_access_token>" } payload: N/A
In the response, you can find the trigger defined for this task, for example:
"trigger": { "type": "ONCE", "interval": 1, "startDate": "2019-09-25", "timeZone": "Europe/London", "atTimes": { "type": "AT_TIME", "times": [ "10:00" ], "time": "10:00", "startTime": "10:00", "endTime": "23:00", "interval": "10" }, "atDays": { "type": "DAY_OF_WEEK", "day": 3, "days": [ "MONDAY", "WEDNESDAY", "FRIDAY" ] } }
Note that a webhook trigger is not supported by a schedule. Therefore, if a task instance is using a webhook trigger, you need to keep it as is.
-
Create a new schedule and paste the entire objects of these triggers you got from the previous step in this schedule.
-
Added a
name
field to each of these triggers.The example above could now read like:
"trigger": { "name": "My unique once trigger" "type": "ONCE", "interval": 1, "startDate": "2019-09-25", "timeZone": "Europe/London", "atTimes": { "type": "AT_TIME", "times": [ "10:00" ], "time": "10:00", "startTime": "10:00", "endTime": "23:00", "interval": "10" }, "atDays": { "type": "DAY_OF_WEEK", "day": 3, "days": [ "MONDAY", "WEDNESDAY", "FRIDAY" ] } }
-
Simulate upcoming events to be triggered by that schedule and assign this schedule to your task. For further information about the whole procedure, see Using a schedule to organize your task runs.
This task could be a new instance duplicated from the above-mentioned task instances or simply one of those task instances. This new schedule and its triggers replace any existing triggers of the target task.
-
Remove all duplicate tasks since they are not useful anymore.
Results
Once done, your task contains all the time triggers that once needed to be added each for a duplicated instance of the task.
You can issue a GET
request to https://api.<env>.cloud.talend.com/orchestration/executables/tasks/<taskId>/run-config
to check the response. In the Trigger
object, the type
field now displays MULTIPLE
.
{
"trigger": {
"type": "MULTIPLE"
},
"runtime": {
"type": "CLOUD"
},
"parallelExecutionAllowed": false,
"logLevel": "WARN"
}