简体   繁体   中英

How to terminate process after certain duration in Netflix Conductor

I am trying to fork the process after it starts into parallel executions in Netflix Conductor . Some form an actual flow and the last one should be timer. So if the execution will not finish within the timer expiration time, eg 3 days, it will be terminated. I have defined the following workflow definition, but WAIT task with durations seems to have no effect.

工作流定义


{
  "updateTime": 1658740176408,
  "name": "test_definiton",
  "description": "Edit or extend this sample workflow. Set the workflow name to get started",
  "version": 1,
  "tasks": [
    {
      "name": "fork_join",
      "taskReferenceName": "my_fork_join_ref",
      "inputParameters": {},
      "type": "FORK_JOIN",
      "decisionCases": {},
      "defaultCase": [],
      "forkTasks": [
        [
          {
            "name": "process_notification_payload",
            "taskReferenceName": "process_notification_payload_email",
            "inputParameters": {},
            "type": "SIMPLE",
            "decisionCases": {},
            "defaultCase": [],
            "forkTasks": [],
            "startDelay": 0,
            "joinOn": [],
            "optional": false,
            "defaultExclusiveJoinTask": [],
            "asyncComplete": false,
            "loopOver": []
          },
          {
            "name": "email_notification",
            "taskReferenceName": "email_notification_ref",
            "inputParameters": {},
            "type": "SIMPLE",
            "decisionCases": {},
            "defaultCase": [],
            "forkTasks": [],
            "startDelay": 0,
            "joinOn": [],
            "optional": false,
            "defaultExclusiveJoinTask": [],
            "asyncComplete": false,
            "loopOver": []
          }
        ],
        [
          {
            "name": "process_notification_payload",
            "taskReferenceName": "process_notification_payload_sms",
            "inputParameters": {},
            "type": "SIMPLE",
            "decisionCases": {},
            "defaultCase": [],
            "forkTasks": [],
            "startDelay": 0,
            "joinOn": [],
            "optional": false,
            "defaultExclusiveJoinTask": [],
            "asyncComplete": false,
            "loopOver": []
          },
          {
            "name": "sms_notification",
            "taskReferenceName": "sms_notification_ref",
            "inputParameters": {},
            "type": "SIMPLE",
            "decisionCases": {},
            "defaultCase": [],
            "forkTasks": [],
            "startDelay": 0,
            "joinOn": [],
            "optional": false,
            "defaultExclusiveJoinTask": [],
            "asyncComplete": false,
            "loopOver": []
          }
        ],
        [
          {
            "name": "wait_task",
            "taskReferenceName": "wait_task_ref",
            "inputParameters": {
              "duration": "3 days"
            },
            "type": "WAIT",
            "decisionCases": {},
            "defaultCase": [],
            "forkTasks": [],
            "startDelay": 0,
            "joinOn": [],
            "optional": false,
            "defaultExclusiveJoinTask": [],
            "asyncComplete": false,
            "loopOver": []
          },
          {
            "name": "terminate",
            "taskReferenceName": "terminate0",
            "inputParameters": {
              "terminationStatus": "FAILED"
            },
            "type": "TERMINATE",
            "decisionCases": {},
            "defaultCase": [],
            "forkTasks": [],
            "startDelay": 0,
            "joinOn": [],
            "optional": false,
            "defaultExclusiveJoinTask": [],
            "asyncComplete": false,
            "loopOver": []
          }
        ]
      ],
      "startDelay": 0,
      "joinOn": [],
      "optional": false,
      "defaultExclusiveJoinTask": [],
      "asyncComplete": false,
      "loopOver": []
    },
    {
      "name": "notification_join",
      "taskReferenceName": "notification_join_ref",
      "inputParameters": {},
      "type": "JOIN",
      "decisionCases": {},
      "defaultCase": [],
      "forkTasks": [],
      "startDelay": 0,
      "joinOn": [
        "email_notification_ref",
        "sms_notification_ref"
      ],
      "optional": false,
      "defaultExclusiveJoinTask": [],
      "asyncComplete": false,
      "loopOver": []
    },
    {
      "name": "finish",
      "taskReferenceName": "finish_ref",
      "inputParameters": {
        "terminationStatus": "COMPLETED"
      },
      "type": "TERMINATE",
      "decisionCases": {},
      "defaultCase": [],
      "forkTasks": [],
      "startDelay": 0,
      "joinOn": [],
      "optional": false,
      "defaultExclusiveJoinTask": [],
      "asyncComplete": false,
      "loopOver": []
    }
  ],
  "inputParameters": [],
  "outputParameters": {
    "data": "${get_population_data.output.response.body.data}",
    "source": "${get_population_data.output.response.body.source}"
  },
  "schemaVersion": 2,
  "restartable": true,
  "workflowStatusListenerEnabled": false,
  "ownerEmail": "example@email.com",
  "timeoutPolicy": "ALERT_ONLY",
  "timeoutSeconds": 0,
  "variables": {},
  "inputTemplate": {}
}

Can you help me to determine whether I made a mistake or suggest alternative? Perhaps with an option to call failure sub workflow.

Wait task eventually gets finished, though not exactly as it should. Setting duration for 1 minute resulted in a waiting time of 33 minutes.

This can be configured, using eg an external SQS, for example, Amazon SQS. More information can be found in the official documentation https://conductor.netflix.com/reference-docs/event-task.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM