All Products
Search
Document Center

ApsaraVideo Media Processing:Receive notifications

Last Updated:Jul 19, 2023

After a notification is sent, you can receive the notification in the specified Message Service (MNS) queue or topic. This topic describes how to receive notifications.

Prerequisites

The notification feature is enabled. For more information, see Enable the notification feature for jobs or workflows.

Receive notifications in an MNS queue

Receive notifications in an MNS topic

Message format for a job

Parameter

Description

jobId(JobId)

The ID of the job.

requestId(RequestId)

The ID of the request.

type(Type)

The type of the job. Valid values:

  • Transcode: a transcoding job

  • Analysis: an intelligent template analysis job

  • Snapshot: a snapshot job

  • MediaInfo: a media information analysis job

state(State)

The status of the job. Valid values:

  • Success: The job is successful.

  • Fail: The job fails.

code

The error code returned when the job fails.

msg

The error message returned when the job fails.

{
    "jobId":"0ceb045cd8df4db49f1c5bd4ace5****",
    "requestId":"713C4BA2-E65A-5984-88D6-C4554DD3****",
    "Type":"Transcode",
    "state":"Success",
    "type":"Transcode",
    "State":"Success",
    "JobId":"0ceb045cd8df4db49f1c5bd4ace5****",
    "RequestId":"713C4BA2-E65A-5984-88D6-C4554DD3****"
}

Message format for a workflow

A message that is sent as a notification on a media workflow is in the JSON format. For more information about the parameters in the message, see the description of media workflow messages in the AddMedia topic.

Message structure:

  • Start

    The activity type in the basic attributes of the activity is Start.

  • Structure

    The following code shows the structure.

  • Report

    The activity type in the basic attributes of the activity is Report.

  • Sample code

    { 
          // The parameters in the top level, which are in the JSON format. The parameters define the basic attributes of the activity and the information about the workflow.
          // The basic attributes of the activity are not independent objects, but key-value pairs that directly belong to the top level. The basic attributes include the ID of the workflow instance, activity name, activity type, activity status, and error message if the workflow fails.
          "RunId": "8f8aba5a62ab4127ae2add18da20****",
          "Name": "Act-4",
          "Type": "Report",
          "State": "Success",
          // The information about the workflow, which is in the JSON format. The information includes the ID of the workflow instance, the ID of the media workflow, the name of the media workflow, the media ID, the input file, the type of the workflow instance, the array of activity objects, and the time when the workflow instance is created.
          "MediaWorkflowExecution": {
            "Name": "ConcurrentSuccess",
            "RunId": "8f8aba5a62ab4127ae2add18da20****",
            "Input": {
                "InputFile": {
                    "Bucket": "exampleBucket****",
                    "Location": "oss-test", 
                   "Object": "mediaWorkflow/ConcurrentSuccess/01.wmv",
               }
            },
            "State": "Success",
            "MediaId": "2be491ab4cb6499cd0befe5fcf0c****",
            // The array of activity objects, which is in the JSON format. The array includes all activity objects related to the current workflow execution status.
            // For example, only the Start activity object is included in a message for notifying you that the execution of the workflow starts, and all activity objects are included in a message for notifying you that the execution of the workflow ends. 
            // Example: Activity object 1, Activity object 2,...
            "ActivityList": 
    [
                // The information about the activity object, which is in the JSON format. The information includes the activity name, activity type, job ID, activity status, start time, end time, and the error message if the activity fails.    
                {
                    "RunId": "8f8aba5a62ab4127ae2add18da20****",
                    "Name": "Act-1",
                    "Type": "Start",
                    "State": "Success",
                    "StartTime": "2016-03-15T02: 53: 41Z",
                    "EndTime": "2016-03-15T02: 53: 41Z",
                },
                {                
                    "RunId": "8f8aba5a62ab4127ae2add18da20****",
                    "Name": "Act-2",
                    "Type": "Transcode",
                    "JobId": "f34b6d1429dd491faa7a6c1c8f90****",
                    "State": "Success",
                    "StartTime": "2016-03-15T02: 53: 43Z",
                    "EndTime": "2016-03-15T02: 53: 47Z",
                },
                {                
                    "RunId": "8f8aba5a62ab4127ae2add18da20****",
                    "Name": "Act-3",
                    "Type": "Snapshot",
                    "JobId": "c14150be33304825a5d67cd5364c****",
                    "State": "Success",
                    "StartTime": "2016-03-15T02: 53: 44Z",                
                    "EndTime": "2016-03-15T02: 53: 45Z",
                },
                {                
                    "RunId": "8f8aba5a62ab4127ae2add18da20****",
                    "Name": "Act-4",
                    "Type": "Report",
                    "State": "Success",
                    "StartTime": "2016-03-15T02: 53: 49Z",
                    "EndTime": "2016-03-15T02: 53: 49Z", 
               }
            ],
            "CreationTime": "2016-03-15T02: 53: 39Z",
          }
      }