Example: Checking for Data Integration trigger events

Updated at:

After you register, publish, and enable an extension on the DataWorks Open Platform, when you use specific features (that is, trigger extension point events) in the workspace where the extension takes effect, DataWorks sends event messages to your extension, and you can view the results returned by the extension. This topic describes the extension point events supported by Data Integration and shows how to use them to trigger custom validation from your extension.

Prerequisite

Background

  • Enable an extension: You can view Extensions on the workspace page and enable or disable extension validation in the current workspace.

  • Extension point events supported by Data Integration:

    • The Data Integration module in DataWorks supports extension point events such as Enable Task and Batch Enable Tasks, which are pre-start events. For the concepts and a detailed list of extension point events, see Extensions.

    • DataWorks can send notifications when these events occur, allowing your extension to automatically validate the operation and send a response. For more details about how extension points are triggered, see Example: Checking events during data development.

Limitations

After an extension is enabled, the following limitations apply to event notifications and responses when a Data Integration task triggers an extension point event.

  • The extension is effective only during the startup phase of a Data Integration solution.

  • Once enabled, the workflow is intercepted when you Start a Data Integration solution. The process enters the Operation Check state, where your extension validates the operation and returns a result. The extension is not triggered for other operations on the solution, such as deletion or modification.

  • The Open Platform uses EventBridge to interact with your services. The message body must not exceed 1 MB. A Data Integration solution can synchronize up to 5,000 tables with unlimited columns, so the message body can easily exceed the 1 MB limit. To prevent this, the following rules apply:

    • For tasks that synchronize 500 or fewer tables, the message includes source table names but not destination column names.

    • For tasks that synchronize more than 500 tables, the message includes only the job ID and no source table names. You must call an OpenAPI operation to get the full details.

Overview

The Data Integration module lets your on-premises services receive messages for specific extension point events. You can also register your on-premises program as a DataWorks extension to process these events with custom logic. Your extension can then use a callback to the CallbackExtension API to send the processing result back to the platform. This enables custom process control within DataWorks. The following lists the extension points that Data Integration supports.

Event name

Event description

Enable Task

A pre-start event for starting a Data Integration task.

Batch Enable Tasks

A pre-start event for starting Data Integration tasks in batches.

Enable an extension

After you develop and deploy an extension, go to the DataWorks Administration page of the target workspace. On the Tenant Configuration > Extensions page, Enable the extension for Data Integration trigger events in the current workspace.

  1. Set Extension Scope to Workspace and select the target workspace.

  2. In the extension list, turn on the Enable toggle switch.

  3. In the Extension Data Authorization dialog box, select the risk confirmation check box and click Authorize.

Supported extension points

Intercept a Data Integration task on start

After you configure a Data Integration task, click the Start button in the Actions column to start the task. However, because the extension is enabled, the task does not start normally. Instead, the process enters the Operation Check state. The task starts only after the extension returns parameters to DataWorks through the CallbackExtension API, and DataWorks determines whether to approve the start request based on the returned result.

Intercept Data Integration tasks on batch start

After you configure multiple Data Integration tasks, select multiple tasks on the left side of the Task List, and click the Start button on the bottom bar to start the tasks in batches. However, because the extension is enabled, the tasks do not start normally. Instead, the process enters the Operation Check state. The tasks start only after the extension returns parameters to DataWorks through the CallbackExtension API, and DataWorks determines whether to approve the start request based on the returned result.

Operation check

In your custom program, use the CallbackExtension API to return the following parameters to DataWorks so that the platform can determine whether the operation passes the check.

  • OK: The extension passes the check for the extension point event.

  • FAIL: The extension fails the check for the extension point event. You must view and handle the error in a timely manner to avoid affecting subsequent program execution.

    In the Operation Check dialog box, the table displays check results in the Check Item, Status, Description, and Action columns. Failed check items are indicated by a red icon and a "Check Failed" label.

  • WARN: The extension passes the check for the extension point event, but a warning is returned.

    In the Operation Check dialog box, the table shows that the status of check item test_dlink is Warning.

References

Appendix: Special notes

For tasks that synchronize more than 500 tables, the returned message contains the showTableMapping field. For more information about message formats and field descriptions for Data Integration events, see Data Integration event list and message formats.

  • When the showTableMapping field is true, the tableMapping details are returned.

    ## Message for v2 task startup, table count does not exceed 500
    {
        "datacontenttype": "application/json;charset=utf-8",
        "aliyunaccountid": "111",
        "aliyunpublishtime": "2024-09-12T08:52:35.919Z",
        "data": {
            "extensionBizId": "xxx",
            "extensionBizName": "sync******20240101",
            "blockBusiness": true,
            "operator": "111",
            "setting": {
                "lastStartPosition": "2024-09-11 12:00:00"
            },
            "eventCode": "start-diJob",
            "jobId": 11,
            "forceRun": false,
            "appId": 1,
            "showTableMapping": true,
            "tenantId": 1,
            "startAsV2": false,
            "tableMapping": [
                {
                    "srcTable": "test_001",
                    "dstDatasourceName": "odps_first",
                    "srcDatabaseName": "db_001",
                    "srcDatasourceName": "datasource_001",
                    "dstTable": "ods_test_001"
                },
                {
                    "srcTable": "test_002",
                    "dstDatasourceName": "odps_first",
                    "srcDatabaseName": "db_001",
                    "srcDatasourceName": "datasource_001",
                    "dstTable": "ods_test_002"
                },
                {
                    "srcTable": "test_003",
                    "dstDatasourceName": "odps_first",
                    "srcDatabaseName": "db_001",
                    "srcDatasourceName": "datasource_001",
                    "dstTable": "ods_test_003"
                }
            ]
        },
        "aliyunoriginalaccountid": "111",
        "specversion": "1.0",
        "aliyuneventbusname": "xxx",
        "id": "xxx",
        "source": "acs.dataworks",
        "time": "2024-09-12T16:52:35.874Z",
        "aliyunregionid": "cn-shanghai",
        "type": "dataworks:NodeChange:StartDiJob"
    }
  • When the showTableMapping field is false, the tableMapping details are not returned.

    ##Message for v2 task startup, table count exceeds 500, "showTableMapping": false
    {
        "datacontenttype": "application/json;charset=utf-8",
        "aliyunaccountid": "11*****3538",
        "aliyunpublishtime": "2024-09-10T14:50:14.553Z",
        "data": {
            "eventCode": "start-diJob",
            "jobId": 11,
            "forceRun": false,
            "extensionBizId": "xxx",
            "extensionBizName": "sync_******_20240101",
            "appId": 11,
            "showTableMapping": false,
            "tenantId": 524*****64736,
            "blockBusiness": true,
            "startAsV2": false,
            "operator": "111",
            "setting": {
                "lastStartPosition": "2024-04-12 22:07:02",
                "startDateTime": "2024-09-10 17:00:00",
                "timeZone": "Asia/Shanghai"
            }
        },
        "aliyunoriginalaccountid": "111",
        "specversion": "1.0",
        "aliyuneventbusname": "cbytest",
        "id": "xxx",
        "source": "acs.dataworks",
        "time": "2024-09-10T22:50:14.534Z",
        "aliyunregionid": "cn-shanghai",
        "type": "dataworks:NodeChange:StartDiJob"
    }
    
    {
        "datacontenttype": "application/json;charset=utf-8",
        "aliyunaccountid": "15******516",
        "aliyunpublishtime": "2024-09-12T09:34:09.297Z",
        "data": {
            "eventCode": "start-diJob",
            "jobId": 1,
            "forceRun": false,
            "extensionBizId": "a5de8a*******f75ba",
            "extensionBizName": "sync_*******_20240912_170517",
            "appId": 11,
            "showTableMapping": true,
            "tenantId": 1,
            "blockBusiness": true,
            "startAsV2": false,
            "tableMapping": [
                {
                    "srcTable": "test.*",
                    "dstDatasourceName": "test_db",
                    "srcDatabaseName": ".*",
                    "srcDatasourceName": "mysql_test",
                    "dstTable": "aaa"
                },
                {
                    "srcTable": "shard.*",
                    "dstDatasourceName": "test_db",
                    "srcDatabaseName": ".*",
                    "srcDatasourceName": "mysql_test",
                    "dstTable": "vvv"
                }
            ],
            "operator": "111"
        },
        "aliyunoriginalaccountid": "111",
        "specversion": "1.0",
        "aliyuneventbusname": "xia****1prj",
        "id": "99d59*******c95a9cacc",
        "source": "acs.dataworks",
        "time": "2024-09-12T17:34:09.248Z",
        "aliyunregionid": "cn-shanghai",
        "type": "dataworks:NodeChange:StartDiJob"
    }