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.

Procedure

  1. 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.

  2. Create a new schedule and paste the entire objects of these triggers you got from the previous step in this schedule.

  3. 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"
            ]
          }
        }
    
  4. 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.

  5. 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"
}