功能说明
数据万象支持自定义设置回调 URL,在任务完成后,系统向该 URL 发送 HTTP POST 请求,请求体中包含通知内容。您可通过配置的回调地址及时了解任务处理的进展和状态,以便进行其他业务操作。
回调内容
任务完成后,系统会向您设置的回调地址发送回调内容,包含完整节点数据的内容展示如下:
<Response><EventName>TaskFinish</EventName><JobsDetail><Code>Success</Code><CreationTime>2022-06-30T19:27:39+0800</CreationTime><EndTime>2022-06-30T19:27:42+0800</EndTime><Input><BucketId>test-123456789</BucketId><Object>input/demo.mp4</Object><Region>ap-chongqing</Region></Input><JobId>ja66d6204f86711ec9ca1073b78d316d3</JobId><Message/><Operation><MediaResult><OutputFile><Bucket>test-123456789</Bucket><Md5Info><Md5>e8c802ed78ba7f4c6a2fb5144cba7cbc</Md5><ObjectName>output/out0.mp4</ObjectName></Md5Info><Md5Info><Md5>f5883c1380524eecd1a925657ab17b4c</Md5><ObjectName>output/out1.mp4</ObjectName></Md5Info><ObjectName>output/out0.mp4</ObjectName><ObjectName>output/out1.mp4</ObjectName><ObjectPrefix/><Region>ap-chongqing</Region></OutputFile></MediaResult><Output><Bucket>test-123456789</Bucket><Region>ap-chongqing</Region><StreamExtract><Index>0</Index><Output>output/out0.mp4</Output></StreamExtract><StreamExtract><Index>1</Index><Output>output/out1.mp4</Output></StreamExtract><StreamExtract><Index>2</Index><Output>output/out2.mp4</Output></StreamExtract></Output><UserData>This is my StreamExtract job.</UserData><JobLevel>0</JobLevel></Operation><QueueId>p2242ab62c7c94486915508540933a2c6</QueueId><StartTime>2022-06-30T19:27:40+0800</StartTime><State>Success</State><Tag>StreamExtract</Tag></JobsDetail></Response>
具体的数据内容如下:
节点名称(关键字) | 父节点 | 描述 | 类型 |
Response | 无 | 保存结果的容器 | Container |
Container 节点 Response 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
EventName | Response | 固定值,为 TaskFinish | String |
JobsDetail | Response | Container数组 |
如果任务是通过工作流触发的,Response.JobsDetail.Input 还会包含 CosHeaders 节点,类型为 Container 数组。
Container 节点 CosHeaders 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
Key | Response.JobsDetail.Input.CosHeaders | 自定义 Header 的名称 | String |
Value | Response.JobsDetail.Input.CosHeaders | 自定义 Header 的值 | String |
如果任务是通过工作流触发的,Response.JobsDetail 还会包含 Workflow 节点,类型为 Container。
Container 节点 Workflow 的内容:
节点名称(关键字) | 父节点 | 描述 | 类型 |
RunId | Response.Workflow | 工作流实例 ID | String |
WorkflowId | Response.Workflow | 工作流 ID | String |
WorkflowName | Response.Workflow | 工作流名称 | String |
Name | Response.Workflow | 工作流节点名称 | String |
实际案例
案例 1:通过任务接口触发的任务回调
<Response><EventName>TaskFinish</EventName><JobsDetail><Code>Success</Code><CreationTime>2022-06-30T19:27:39+0800</CreationTime><EndTime>2022-06-30T19:27:42+0800</EndTime><Input><BucketId>test-123456789</BucketId><Object>input/demo.mp4</Object><Region>ap-chongqing</Region></Input><JobId>ja66d6204f86711ec9ca1073b78d316d3</JobId><Message/><Operation><MediaResult><OutputFile><Bucket>test-123456789</Bucket><Md5Info><Md5>e8c802ed78ba7f4c6a2fb5144cba7cbc</Md5><ObjectName>output/out0.mp4</ObjectName></Md5Info><Md5Info><Md5>f5883c1380524eecd1a925657ab17b4c</Md5><ObjectName>output/out1.mp4</ObjectName></Md5Info><ObjectName>output/out0.mp4</ObjectName><ObjectName>output/out1.mp4</ObjectName><ObjectPrefix/><Region>ap-chongqing</Region></OutputFile></MediaResult><Output><Bucket>test-123456789</Bucket><Region>ap-chongqing</Region><StreamExtract><Index>0</Index><Output>output/out0.mp4</Output></StreamExtract><StreamExtract><Index>1</Index><Output>output/out1.mp4</Output></StreamExtract><StreamExtract><Index>2</Index><Output>output/out2.mp4</Output></StreamExtract></Output><UserData>This is my StreamExtract job.</UserData><JobLevel>0</JobLevel></Operation><QueueId>p2242ab62c7c94486915508540933a2c6</QueueId><StartTime>2022-06-30T19:27:40+0800</StartTime><State>Success</State><Tag>StreamExtract</Tag></JobsDetail></Response>
案例 2:通过任务接口触发的任务回调, 格式为 JSON
{"EventName": "TaskFinish","JobsDetail": [{"Code": "Success","CreationTime": "2022-06-30T19:27:39+0800","EndTime": "2022-06-30T19:27:42+0800","Input": {"BucketId": "test-123456789","Object": "input/demo.mp4","Region": "ap-chongqing"},"JobId": "ja66d6204f86711ec9ca1073b78d316d3","Operation": {"MediaResult": {"OutputFile": {"Bucket": "test-123456789","Md5Info": [{"Md5": "e8c802ed78ba7f4c6a2fb5144cba7cbc","ObjectName": "output/out0.mp4"},{"Md5": "f5883c1380524eecd1a925657ab17b4c","ObjectName": "output/out1.mp4"}],"ObjectName": ["output/out0.mp4","output/out1.mp4"],"Region": "ap-chongqing"}},"Output": {"Bucket": "test-123456789","Region": "ap-chongqing","StreamExtract": [{"Index": "0","Output": "output/out0.mp4"},{"Index": "1","Output": "output/out1.mp4"},{"Index": "2","Output": "output/out2.mp4"}]},"UserData": "This is my StreamExtract job.","JobLevel": 0},"QueueId": "p2242ab62c7c94486915508540933a2c6","StartTime": "2022-06-30T19:27:40+0800","State": "Success","Tag": "StreamExtract"}]}