任务回调

最近更新时间:2023-09-12 16:21:44

我的收藏

功能说明

数据万象支持自定义设置回调 URL,在任务完成后,系统向该 URL 发送 HTTP POST 请求,请求体中包含通知内容。您可通过配置的回调地址及时了解任务处理的进展和状态,以便进行其他业务操作。

回调内容

任务完成后,系统会向您设置的回调地址发送回调内容,包含完整节点数据的内容展示如下:
<Response>
<EventName>TaskFinish</EventName>
<JobsDetail>
<Code>Success</Code>
<CreationTime>2022-07-25T16:35:39+0800</CreationTime>
<EndTime>2022-07-25T16:35:43+0800</EndTime>
<Input>
<BucketId>test-123456789</BucketId>
<Object>input/test.mp4</Object>
<Region>ap-chongqing</Region>
</Input>
<JobId>ac34be3aa0bf411ed9ce39d7cc972e427</JobId>
<Message>Success</Message>
<Operation>
<MediaInfo>
<Format>
<Duration>13</Duration>
<NumStream>1</NumStream>
<Size>1909389</Size>
</Format>
<Stream>
<Audio>
<Bitrate>128000</Bitrate>
<Channel>2</Channel>
<ChannelLayout>stereo</ChannelLayout>
<CodecLongName>AAC (Advanced Audio Coding)</CodecLongName>
<CodecName>aac</CodecName>
<CodecTag>0x6134706d</CodecTag>
<CodecTagString>mp4a</CodecTagString>
<CodecTimeBase>1/44100</CodecTimeBase>
<Duration>13.653</Duration>
<Index>1</Index>
<Language>und</Language>
<SampleFmt>fltp</SampleFmt>
<SampleRate>44100</SampleRate>
<StartTime>0.000000</StartTime>
<Timebase>1/44100</Timebase>
</Audio>
<Video>
<AvgFps>50.000</AvgFps>
<Bitrate>1031968</Bitrate>
<CodecLongName>H.265 / HEVC (High Efficiency Video Coding)</CodecLongName>
<CodecName>hevc</CodecName>
<CodecTag>0x31637668</CodecTag>
<CodecTagString>hvc1</CodecTagString>
<CodecTimeBase>1/50</CodecTimeBase>
<ColorPrimaries>bt470bg</ColorPrimaries>
<ColorRange>tv</ColorRange>
<ColorTransfer>smpte170m</ColorTransfer>
<Duration>12.960</Duration>
<FieldOrder>Unknown</FieldOrder>
<Fps>50/1</Fps>
<HasBFrame>4</HasBFrame>
<Height>960</Height>
<Index>0</Index>
<Language>und</Language>
<Level>4</Level>
<NumFrames>648</NumFrames>
<PixFormat>hvc1</PixFormat>
<Profile>Main</Profile>
<RefFrames>1</RefFrames>
<Rotation>0</Rotation>
<StartTime>0.000000</StartTime>
<Timebase>1/12800</Timebase>
<Width>540</Width>
</Video>
</Stream>
</MediaInfo>
<MediaResult>
<OutputFile>
<Bucket>test-123456789</Bucket>
<Md5Info>
<Md5>2db78d168edf2f883adce89a1b4ca033</Md5>
<ObjectName>output/out.mp4</ObjectName>
</Md5Info>
<ObjectName>output/out.mp4</ObjectName>
<ObjectPrefix/>
<Region>ap-chongqing</Region>
</OutputFile>
</MediaResult>
<SegmentVideoBody>
<Mode>Mask</Mode>
</SegmentVideoBody>
<Output>
<Region>ap-chongqing</Region>
<Bucket>test-123456789</Bucket>
<Object>output/out.mp4</Object>
</Output>
<UserData>This is my SegmentVideoBody job.</UserData>
<JobLevel>0</JobLevel>
</Operation>
<QueueId>pbde29b842b1b4e2ea4f0b20d264fcec2</QueueId>
<StartTime>2022-07-25T16:35:39+0800</StartTime>
<State>Success</State>
<Tag>SegmentVideoBody</Tag>
</JobsDetail>
</Response>
具体的数据内容如下:
节点名称(关键字)
父节点
描述
类型
Response
保存结果的容器
Container
Container 节点 Response 的内容:
节点名称(关键字)
父节点
描述
类型
EventName
Response
固定值,为 TaskFinish
String
JobsDetail
Response
同提交视频人像抠图接口中的 Response.JobsDetail
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-07-25T16:35:39+0800</CreationTime>
<EndTime>2022-07-25T16:35:43+0800</EndTime>
<Input>
<BucketId>test-123456789</BucketId>
<Object>input/test.mp4</Object>
<Region>ap-chongqing</Region>
</Input>
<JobId>ac34be3aa0bf411ed9ce39d7cc972e427</JobId>
<Message>Success</Message>
<Operation>
<MediaInfo>
<Format>
<Duration>13</Duration>
<NumStream>1</NumStream>
<Size>1909389</Size>
</Format>
<Stream>
<Audio>
<Bitrate>128000</Bitrate>
<Channel>2</Channel>
<ChannelLayout>stereo</ChannelLayout>
<CodecLongName>AAC (Advanced Audio Coding)</CodecLongName>
<CodecName>aac</CodecName>
<CodecTag>0x6134706d</CodecTag>
<CodecTagString>mp4a</CodecTagString>
<CodecTimeBase>1/44100</CodecTimeBase>
<Duration>13.653</Duration>
<Index>1</Index>
<Language>und</Language>
<SampleFmt>fltp</SampleFmt>
<SampleRate>44100</SampleRate>
<StartTime>0.000000</StartTime>
<Timebase>1/44100</Timebase>
</Audio>
<Video>
<AvgFps>50.000</AvgFps>
<Bitrate>1031968</Bitrate>
<CodecLongName>H.265 / HEVC (High Efficiency Video Coding)</CodecLongName>
<CodecName>hevc</CodecName>
<CodecTag>0x31637668</CodecTag>
<CodecTagString>hvc1</CodecTagString>
<CodecTimeBase>1/50</CodecTimeBase>
<ColorPrimaries>bt470bg</ColorPrimaries>
<ColorRange>tv</ColorRange>
<ColorTransfer>smpte170m</ColorTransfer>
<Duration>12.960</Duration>
<FieldOrder>Unknown</FieldOrder>
<Fps>50/1</Fps>
<HasBFrame>4</HasBFrame>
<Height>960</Height>
<Index>0</Index>
<Language>und</Language>
<Level>4</Level>
<NumFrames>648</NumFrames>
<PixFormat>hvc1</PixFormat>
<Profile>Main</Profile>
<RefFrames>1</RefFrames>
<Rotation>0</Rotation>
<StartTime>0.000000</StartTime>
<Timebase>1/12800</Timebase>
<Width>540</Width>
</Video>
</Stream>
</MediaInfo>
<MediaResult>
<OutputFile>
<Bucket>test-123456789</Bucket>
<Md5Info>
<Md5>2db78d168edf2f883adce89a1b4ca033</Md5>
<ObjectName>output/out.mp4</ObjectName>
</Md5Info>
<ObjectName>output/out.mp4</ObjectName>
<ObjectPrefix/>
<Region>ap-chongqing</Region>
</OutputFile>
</MediaResult>
<SegmentVideoBody>
<Mode>Mask</Mode>
</SegmentVideoBody>
<Output>
<Region>ap-chongqing</Region>
<Bucket>test-123456789</Bucket>
<Object>output/out.mp4</Object>
</Output>
<UserData>This is my SegmentVideoBody job.</UserData>
<JobLevel>0</JobLevel>
</Operation>
<QueueId>pbde29b842b1b4e2ea4f0b20d264fcec2</QueueId>
<StartTime>2022-07-25T16:35:39+0800</StartTime>
<State>Success</State>
<Tag>SegmentVideoBody</Tag>
</JobsDetail>
</Response>

案例 2:通过任务触发的任务回调, 格式为 JSON

{
"EventName": "TaskFinish",
"JobsDetail": [{
"Code": "Success",
"CreationTime": "2022-07-25T16:35:39+0800",
"EndTime": "2022-07-25T16:35:43+0800",
"Input": {
"BucketId": "test-123456789",
"Object": "input/test.mp4",
"Region": "ap-chongqing"
},
"JobId": "ac34be3aa0bf411ed9ce39d7cc972e427",
"Message": "Success",
"Operation": {
"MediaInfo": {
"Format": {
"Duration": "13",
"NumStream": "1",
"Size": "1909389"
},
"Stream": {
"Audio": [{
"Bitrate": "128000",
"Channel": "2",
"ChannelLayout": "stereo",
"CodecLongName": "AAC (Advanced Audio Coding)",
"CodecName": "aac",
"CodecTag": "0x6134706d",
"CodecTagString": "mp4a",
"CodecTimeBase": "1/44100",
"Duration": "13.653",
"Index": "1",
"Language": "und",
"SampleFmt": "fltp",
"SampleRate": "44100",
"StartTime": "0.000000",
"Timebase": "1/44100"
}],
"Video": [{
"AvgFps": "50.000",
"Bitrate": "1031968",
"CodecLongName": "H.265 / HEVC (High Efficiency Video Coding)",
"CodecName": "hevc",
"CodecTag": "0x31637668",
"CodecTagString": "hvc1",
"CodecTimeBase": "1/50",
"ColorPrimaries": "bt470bg",
"ColorRange": "tv",
"ColorTransfer": "smpte170m",
"Duration": "12.960",
"FieldOrder": "Unknown",
"Fps": "50/1",
"HasBFrame": "4",
"Height": "960",
"Index": "0",
"Language": "und",
"Level": "4",
"NumFrames": "648",
"PixFormat": "hvc1",
"Profile": "Main",
"RefFrames": "1",
"Rotation": "0",
"StartTime": "0.000000",
"Timebase": "1/12800",
"Width": "540"
}]
}
},
"MediaResult": {
"OutputFile": {
"Bucket": "test-123456789",
"Md5Info": [{
"Md5": "2db78d168edf2f883adce89a1b4ca033",
"ObjectName": "output/out.mp4"
}],
"ObjectName": ["output/out.mp4"],
"Region": "ap-chongqing"
}
},
"SegmentVideoBody": {
"Mode": "Mask"
},
"Output": {
"Region": "ap-chongqing",
"Bucket": "test-123456789",
"Object": "output/out.mp4"
},
"UserData": "This is my SegmentVideoBody job.",
"JobLevel": "0"
},
"QueueId": "pbde29b842b1b4e2ea4f0b20d264fcec2",
"StartTime": "2022-07-25T16:35:39+0800",
"State": "Success",
"Tag": "SegmentVideoBody"
}]
}