Unlike a scheduled workflow, which runs on a predefined schedule (such as at 1:00 AM every day), a triggered workflow is an on-demand, event-driven data processing model. An external signal—such as a file upload, message arrival, API call, or manual click—triggers its execution in real time, providing excellent real-time responsiveness and flexibility for data processing.
|
Feature |
Scheduled workflow |
Triggered workflow |
|
Trigger mechanism |
Fixed schedule (cron expression) |
External signal (event, API, manual) |
|
Execution model |
Scheduled and predictable |
Reactive and on-demand |
|
Use cases |
T+1 batch data warehousing, scheduled reports |
Process files upon arrival, integrate with business systems, manual data repair |
|
Key advantages |
Reliability and predictable scheduling |
Real-time responsiveness and flexibility |
Supported trigger methods
A triggered workflow supports three trigger methods. Choose one based on your scenario.
|
Trigger method |
Initiator |
Core scenarios |
Key points |
|
Event trigger |
External event source (such as OSS or ApsaraMQ for Kafka) |
Event-driven ETL: Process files as they arrive, or trigger real-time computation from messages. |
You must first Create a trigger and associate it with the workflow. This takes effect only in the production environment. |
|
Manual trigger |
User (developer/O&M engineer) |
Ad hoc tasks: One-time data processing or analysis. |
You can manually run the workflow in both the development and production environments. This is the recommended alternative to manual workflows. |
|
API trigger |
External system (through OpenAPI) |
System integration: Triggered by callbacks from business systems (such as CRM or ERP) to initiate data processing. |
You must call an OpenAPI operation and have the required permissions. |
Quick start: Create a manually triggered workflow
This section walks you through creating a simple triggered workflow and running it manually so that you can quickly experience the end-to-end process.
Step 1: Create a triggered workflow
Go to the Workspaces page in the DataWorks console. In the top navigation bar, select a desired region. Find the desired workspace and choose in the Actions column.
-
In the left-side navigation pane, click
, and then click on the right side of Project Directory to go to the Create Workflow page. -
In the dialog box that appears, on the Create Workflow page, set Scheduling Type to Triggered scheduling. Enter a workflow Name and click Confirm to create the workflow.
Step 2: Orchestrate the workflow and develop nodes
-
Click + Add Node on the toolbar to open the node list. Drag a Shell node from the node type list on the left onto the canvas, enter a name, and complete the creation.
-
Double-click the Shell node to go to the code editing page, and enter the following code:
echo "Hello, Trigger Workflow! Current time is ${bizdate}" -
Click the Save button on the toolbar.
Step 3: Debug and run (development environment)
-
Go back to the workflow canvas and click the
icon on the top toolbar. -
In the dialog box that appears, enter the Value Used in This Run for the workflow (for example, if today is 20260310,
bizdateshould be replaced with20260309). -
After a moment, in the run log at the bottom, you can see the running status of the node and the output of the
echocommand.
Step 4: Deploy and run (production environment)
-
On the workflow canvas, click the Deploy
button and follow the prompts to complete the deployment process. -
After successful deployment, go to Operation Center > Manually Triggered Task O&M > Manually Triggered Task > Triggered Workflow.
-
Find the workflow you just deployed, and click Run in the Operation column.
-
In the dialog box that appears, click Run again to trigger an instance of the workflow in the production environment. You can view the details of this run on the Manual Instances page.
You have now mastered the basic usage of triggered workflows. Next, we will explore the more powerful event-triggered capabilities.
Advanced example: Create an event-triggered workflow
Scenario 1: A new file arrives in OSS, automatically triggering data processing
Goal: When a new CSV file is uploaded to a specified directory in OSS, automatically trigger a workflow that prints the file path.
Step 1: Create an OSS trigger
-
Go to Operation Center > Scheduling Settings > Trigger Management.
-
Click Create Trigger and configure as follows:
NoteFor detailed parameter descriptions, see OSS trigger.
-
Trigger Name: Enter a custom name, such as
oss_new_file_trigger. -
Applicable Workspace: Select the target workspace where the workflow resides.
-
Trigger Event Type: Select
Object Storage Service (OSS). -
Trigger Event: Select
oss:ObjectCreated:PutObject(or another upload event). -
Bucket Name: Select your OSS bucket.
-
File Name: Specify the file path and format to monitor. Wildcards are supported. For example, to monitor all
.csvfiles in theinput/directory, enterinput/*.csv. -
Role Configuration: For first-time use, perform One-Click Authorization and select the role named
DataWorks-EventBridge-OSS-MNS-Role-*************.*************represents a randomly generated 13-digit ID number used for uniqueness.
-
-
Click Confirm to complete the trigger creation.
Step 2: Create and associate a workflow
-
Follow the steps in Quick start: Create a manually triggered workflow to create a new triggered workflow named
process_oss_file_workflow. -
In the right-side panel of the workflow canvas, navigate to Scheduling Settings > Scheduling Policy.
-
In the Trigger drop-down list, select the
oss_new_file_triggertrigger you just created.After selecting a trigger, you can use
${workflow.triggerMessage}in internal tasks to obtain the complete message body, or use${workflow.triggerMessage.xxx}to obtain the value of a specific field in the message body.
Step 3: Develop a node and parse event parameters
-
Click + Add Node on the toolbar to open the node list. Drag a Shell node from the node type list on the left onto the canvas, enter a name, and complete the creation.
-
Double-click the node and write code to retrieve and print the file path from the trigger event.
-
General usage: The following parameter usage applies to most event messages.
# When a trigger fires the workflow, event info is passed in via the built-in variable workflow.triggerMessage # We can get the full path of the uploaded file via ${workflow.triggerMessage.data.oss.object.key} echo "========= Start Processing OSS File =========" message='${workflow.triggerMessage}' echo "Raw Value: ${message}" # Extract the file name from the event message FILE_PATH='${workflow.triggerMessage.data.oss.object.key}' echo "A new file has arrived: ${FILE_PATH}" # Add specific processing logic here echo "========= Finish Processing OSS File =========" -
Special case: Some nodes, such as Shell nodes, have their own syntax rules. Before the node runs, the scheduling engine first substitutes the message content into the script text and then passes it to the Shell interpreter for execution. As a result, the quotation marks, spaces, and line breaks in the message directly participate in Shell syntax parsing. This may cause the spaces or line breaks in the parameter to break the original code structure after the node retrieves the parameter. In this case, you can use a heredoc to read the message, which avoids most special-character issues:
# Use a heredoc to safely capture the raw text substituted from ${workflow.triggerMessage}. message=$(cat <<'__DW_TRIGGER_MESSAGE__' ${workflow.triggerMessage} __DW_TRIGGER_MESSAGE__ ) # Scenario 1: Get the entire raw message printf 'Raw Value: %s\n' "$message" # Scenario 2: If you need only a specific field, use Python to parse the JSON and extract the value dt=$(printf '%s' "$message" | /home/tops/bin/python3 -c 'import json,sys; print(json.load(sys.stdin).get("body",{}).get("dt",""))') printf 'dt=%s\n' "$dt"Note${workflow.triggerMessage}: Retrieves the complete event message body in JSON format. You can obtain the specific message format for OSS from EventBridge > Event Bus >
DATAWORKS_TRIGGER_FOR_BUCKET_<OSS_Bucket_Name>> Event Tracing > Event Details.
-
Step 4: Debug and publish
-
Debug:
-
Return to the workflow canvas and click the Run
button. -
In the Trigger Message Body input box, paste a simulated OSS event JSON. You can copy and modify the
keyvalue from the "Message Format Sample" on the trigger configuration page. The following is a simple example.{ "data": { "oss":{ "object": { "key": "input/test_file_20260310.csv" } } } } -
Click Run and check whether
input/test_file_20260310.csvis successfully printed in the logs.
-
-
Publish: After debugging is successful, click the Publish button to deploy the workflow to the production environment. Event triggers take effect only in the production environment.
Step 5: Verify in production
-
Use the OSS console or a client tool to upload a CSV file to the bucket and path (for example, the
input/directory) that you configured in the trigger. -
Go to DataWorks Operation Center > Manually Triggered Task O&M > Manually Triggered Task > Triggered Workflow. The successfully published
process_oss_file_workflowappears. -
Wait a moment and then go to DataWorks Operation Center > Manually Triggered Task O&M > Triggered Workflow Instance. A new workflow instance is automatically triggered. Click to view its logs and verify that the file path is correctly processed.
===== Start Processing 0SS File ===== Raw Value: {"datacontenttype":"application/json;charset=utf-8","aliyunaccountid":"1162423445433459","data":{"eventVersion":"1.0","responseElements":{"requestId":"69B1083F7A439F343040ABCD"}, "eventSource":"acs:oss","eventTime":"2026-03-11T06:14:23.000Z","requestParameters":{"sourceIPAddress":"140.205.11.13"},"eventName":"0bjectCreated:Post0bject","userIdentity":{"principalId":"1162423445433459"}, "region":"cn-hangzhou","oss":{"bucket":{"name":"dwoss1024","arn":"acs:oss:cn-hangzhou:1162423445433459:dwoss1024","virtualBucket":"","ownerIdentity":"1162423445433459"},"ossSchemaVersion":"1.0","object":{"size":59537,"objectMeta": {"mimeType":"text/csv"},"deltaSize":0,"eTag":"63B4BA5A45AEFC679B9A917E8DDF0D32","key":"input/2013-2020-global-PS4-game-sales.csv"}}},"subject":"acs:oss:cn-hangzhou:1162423445433459:dwoss1024/input/2013-2020-global-PS4-game-sales.csv","aliyunoriginalaccountid":"1162423445433459","source":"acs.oss","type":"oss:0bjectCreated:Post0bject","aliyunpublishtime":"2026-03-11T06:14:23.959Z","specversion":"1.0","aliyuneventbusname":"DATAW0RKS_TRIGGER_F0R_BUCKET_dwoss1024","id":"69B1083F7A439F343040ABCD","time":"2026-03-11T06:14:23.000Z","aliyunregionid":"cn-hangzhou"}A new file has arrived: input/2013-2020-global-PS4-game-sales.csv ====== Finish Processing 0SS File =========
Best practice: Idempotent design
Due to factors such as network fluctuations, OSS events may be delivered more than once. To avoid duplicate data processing, we recommend that you implement idempotency in your business logic. A common approach is to check a record table (such as a MaxCompute table) before processing a file. Use the file's ETag or unique path as the identifier and skip the file if it has already been processed.
Scenario 2: Kafka message arrival drives real-time computation
Objective: Monitor user behavior logs in Kafka. When new messages arrive, trigger a workflow to parse them and execute different logic based on the content.
Step 1: Create a Kafka trigger
-
Go to Operation Center > Scheduling Settings > Trigger Management, and click Create Trigger.
-
Configure the following settings:
-
Trigger Name:
kafka_user_action_trigger. -
Trigger Event Type: Select ApsaraMQ for Kafka.
-
Kafka Instance and Topic: Select the instance and topic that you want to monitor.
-
ConsumerGroupId: We recommend that you select Quick Create. The system automatically generates a consumer group ID to avoid conflicts with other applications.
-
Key (optional): You can specify a message key. Only messages whose key exactly matches the specified value trigger the workflow.
-
-
Click OK.
Step 2: Create and associate a workflow
-
Follow the steps in Quick start: Create a manually triggered workflow to create a triggered workflow named
handle_user_action_workflow. -
In the right-side panel of the workflow canvas, select Scheduling Settings > Scheduling Policy.
-
In the Trigger drop-down list, select the
kafka_user_action_triggertrigger that you just created.After you select a trigger, you can use
${workflow.triggerMessage}in internal nodes to retrieve the complete message body, or use${workflow.triggerMessage.xxx}to retrieve the value of a specific field in the message body. -
(Important) Because messages may arrive at a high frequency, we recommend that you configure Maximum Parallel Instances for Internal Tasks, such as
100, to prevent a sudden surge of messages from overwhelming scheduling resources.
Step 3: Develop nodes and parse nested JSON
Assume that the value field of the Kafka message is a JSON string in the following format: {"user_id": "1001", "action_type": "login", "timestamp": 1688888888}.
-
Click + Add Node on the toolbar to open the node list. Drag a Python node from the node type list on the left side to the canvas.
-
Write code to parse the message. Because the
valuefield itself is a string, you need to perform a secondary JSON parse in the code.import json # 1. Use the built-in variable to get the value field of the Kafka message, which is a JSON string message_value_str = '${workflow.triggerMessage.value}' print(f'Received raw message value string: ${message_value_str}') try: # 2. Parse this string into a JSON object (dictionary) in Python message_data = json.loads(message_value_str) user_id = message_data.get("user_id") action_type = message_data.get("action_type") print(f"Successfully parsed message. User ID: ${user_id}, Action: ${action_type}") # 3. Execute different business logic based on the action_type if action_type == 'login': # o.run_sql(f"INSERT OVERWRITE TABLE user_login_record PARTITION(ds='{bizdate}') VALUES ('{user_id}');") print("Processing login action...") elif action_type == 'purchase': print("Processing purchase action...") else: print("Unknown action type.") except json.JSONDecodeError as e: print(f"Error decoding JSON: {e}") # Exception handling logic, e.g., write the error message to a dedicated log table raise e # Raise the exception to fail the node for easier troubleshooting
Step 4: Debug and publish
-
Debugging:
-
Return to the workflow canvas and click the Run
button. -
In the Trigger Message Body, paste the simulated Kafka event. Note that the
valuefield is an escaped JSON string.{ "topic": "user-behavior-topic", "key": "some-key", "value": "{\"user_id\": \"1001\", \"action_type\": \"login\", \"timestamp\": 1688888888}" } -
Run the workflow and check the logs to confirm that the Python node can correctly parse
user_idandaction_type.
-
-
Publishing: After debugging is successful, publish the workflow to the production environment.
Step 5: Production verification
-
Send a properly formatted message to the Kafka topic you configured.
On the Topic details page, click Quick Experience Message Sending and Receiving and select the Console sending method. Enter
some-keyin Message Key, enter{"user_id": "1001", "action_type": "login", "timestamp": 1688888888}in Message Content, set Send to Specified Partition to No, and click Send. If the page displays Message sent successfully, the verification is passed. -
Go to DataWorks Operation Center > Manually Triggered Task O&M > Manually Triggered Task > Triggered Workflow. The successfully published
handle_user_action_workflowappears. -
In Operation Center > Manually Triggered Task O&M > Manual instance > Triggered Workflow Instance, check whether a new workflow instance has been triggered and review its run logs.
2026-xxx 14:55:40 INFO ======================================================================== Received raw message value string: ${"user_id": "1001", "action_type": "login", "timestamp": 1688888888} Successfully parsed message. User ID: $1001, Action: $login Processing login action... 2026-xxx 14:55:40 INFO ========================================================================
Best practices: Concurrency and ordering
-
Concurrency control: Make sure that you set a reasonable maximum number of parallel instances to handle message spikes.
-
Ordering guarantee: DataWorks scheduling does not guarantee strict in-order message processing. If you need to ensure that messages for the same user (or partition) are processed in order, implement distributed locking in your business code (for example, based on Redis or MaxCompute), or delegate the processing logic to a compute engine that guarantees partition-ordered consumption (such as Flink).
Core design and configuration
Workflow orchestration
The core orchestration process for triggered workflows is similar to that of scheduled workflows. For more information, see Node/workflow orchestration.
Scheduling parameters
In the Scheduling Settings panel on the right side of the workflow canvas, you can set global parameters for the workflow. All nodes within the workflow can reference these parameters.
-
Reference method: In node code, reference workflow parameters in the format
${workflow.parameter_name}. -
Parameter priority: Parameters in DataWorks follow a hierarchical override rule. The priority order is: Node parameters > Workflow parameters.
For more information about parameters, see Parameter design and flow.
Scheduling policy
When multiple workflows or tasks are triggered simultaneously and system resources become a bottleneck, you can use Priority and Weighting Strategy to implement intelligent resource scheduling and ensure that the most important tasks are executed first.
-
Safeguard core business: Set a higher priority for core business workflows so that they always run before other non-core workflows.
-
Reduce critical path duration: Within the same workflow instance, by using Priority weighting strategy, you can influence the execution order of nodes. For example, with the Downstream weighting strategy, nodes on the critical path that have more upstream dependencies receive higher dynamic weights and are executed first, effectively reducing the overall workflow run duration.
Configuration item
Description
Priority
Defines the absolute priority level of workflow instances in the scheduling queue. Available levels are 1, 3, 5, 7, and 8 (the larger the number, the higher the priority). Tasks or workflows with higher priority always acquire scheduling resources before those with lower priority.
Priority weighting strategy
Defines how the dynamic weight of each node (task) within a workflow is calculated at the same priority level. Nodes with higher weights are executed first.
-
No weighting: All nodes have the same fixed baseline weight.
-
Downstream weighting: Node weights are dynamically adjusted. The more upstream dependencies a node has, the higher its weight. This strategy helps nodes on the critical path of the DAG (directed acyclic graph) to be executed first. The weight is calculated as:
initial weight value + sum of priorities of all upstream nodes.
Maximum Parallel Instances for Internal Tasks
Controls the maximum number of instances of this workflow that can run concurrently. This is used for concurrency control and resource protection. When the number of running instances reaches the limit, subsequently triggered new instances enter a waiting state. You can set it to Allowed or specify a custom maximum value (up to 100,000).
NoteIf you set the limit to a value that exceeds the maximum capacity of the resource group, the actual concurrency bottleneck is determined by the physical limit of the resource group.
-
The priority system in DataWorks follows a hierarchical override rule: Runtime specification > Node-level configuration > Workflow-level configuration.
-
Workflow-level configuration (baseline): Configured in the Scheduling Policy of the workflow and serves as the default setting for all nodes.
-
Node-level configuration (local): In the Scheduling Settings > Scheduling Policy of an individual node within the workflow, you can set a higher Priority for a specific node, which overrides the workflow-level setting.
-
Runtime specification (temporary): Specified through the Runtime Priority Reset toggle when you manually trigger a run in Operation and Maintenance Center. This configuration has the highest priority, takes effect only for the current run, and does not modify any permanent configuration.
O&M and management
-
Instance monitoring: All triggered or manually run instances can be viewed, rerun, terminated, and troubleshot on the Operation Center > Manually Triggered Task O&M > Manual Instance page.
-
Monitoring and alerting: You can create a custom rule in Operation Center > Monitoring and Alerting > Rule Management. After you turn on Monitor Triggered Workflows, the rule monitors only triggered workflow instances. For more information about how to configure the rule, see Rule management.
-
Clone a workflow: Right-click a workflow in the Project Directory and select Clone to quickly create a copy that includes all nodes and dependencies. For more information, see Clone a workflow for scheduled workflows.
-
Version management: On the Versions panel on the right side of the workflow canvas, you can view, compare, and restore historical versions of a workflow. For more information, see Version management for scheduled workflows.
Usage limits and considerations
-
Effective environment: The event trigger mechanism takes effect only after the workflow is deployed to the production environment (Operation Center).
-
Node count: A single workflow supports up to 400 nodes. We recommend that you keep the number within 100 to simplify maintenance.
-
Resource group restriction: Nodes created in a triggered workflow can only use serverless resource groups.
-
Concurrency limit: The maximum number of parallel instances is 100,000, but the actual concurrency is limited by the specifications of the scheduling resource group that you purchased.
-
Node-level scheduling: When you configure scheduling at the node level, only Priority is supported. Priority Weighting Policy is not supported.
-
Unsupported node types: EMR Spark Streaming, Flink SQL Streaming, Flink JAR Streaming, Flink Python Streaming, and dependency check nodes cannot be used in triggered workflows. These node types can only be developed and run as standalone nodes.