ApsaraVideo VOD supports event notifications through HTTP (and HTTPS) callbacks and Simple Message Queue (formerly MNS) callbacks. This topic describes event types, callback methods, configurations, protocols, common parameters, validation, the retry policy, and frequently asked questions (FAQ).
Introduction to event notifications
ApsaraVideo VOD supports multiple storage regions. You can configure a unique callback method and webhook address for event notifications in each region. After a video is uploaded and processed, ApsaraVideo VOD sends a notification based on the callback method and webhook address configured for that region.
The callback body returns only HTTP URLs. HTTPS URLs are not supported. For information about how to obtain HTTPS URLs, see the FAQ about event notifications.
Callback methods
ApsaraVideo VOD supports two methods for receiving event notifications: HTTP (and HTTPS) callbacks and Simple Message Queue (MNS) callbacks.
HTTP (and HTTPS) callbacks:
HTTP callbacks are a passive method for receiving event notifications from ApsaraVideo VOD. With this method, you deploy an HTTP service to receive callback messages and configure the webhook address in ApsaraVideo VOD. When an event occurs, the VOD service sends an HTTP POST request to this address, and the event notification is delivered in the HTTP body.
Simple Message Queue (formerly MNS) callbacks:
Simple Message Queue (formerly MNS) callbacks are an active method that lets you pull event notifications from ApsaraVideo VOD. After you grant ApsaraVideo VOD access to MNS, you can create or use an existing queue in Simple Message Queue (formerly MNS) and configure event notifications in ApsaraVideo VOD. When an event occurs, ApsaraVideo VOD writes the callback content to the queue. You must then retrieve the message from the Simple Message Queue (formerly MNS) queue. For more information about how to create a queue and receive messages in the Simple Message Queue (formerly MNS) console, see Queue operations.
Comparison of HTTP and MNS callbacks
Item | HTTP callback | MNS callback (Recommended) |
Reliability | If your HTTP message receiving service is abnormal, such as if it crashes or restarts, messages may be lost. | More reliable. Callbacks almost always succeed with a proper configuration. |
Security | Anyone can send a request to the webhook address. However, you can use callback authentication to filter illegal requests and improve security. For more information, see HTTP callback authentication. | More secure because only authorized parties can read from and write to the message queue. |
Convenience | More convenient to integrate. Simply deploy a message receiving service. | Requires activating and configuring Simple Message Queue (formerly MNS). You also need to develop and deploy a program to consume messages. |
Callback protocols
HTTP callbacks
Request: An HTTP POST request with a JSON body. For more information about the specific body content of each callback, see the documents referenced in Event types.
Response: ApsaraVideo VOD ignores the response body content.
Simple Message Queue (formerly MNS) callbacks
The received message content is in JSON format. For more information about the specific body content of each callback, see the documents referenced in Event types.
Common callback parameters
Parameter | Type | Description |
EventTime | String | The time when the event occurred, in UTC. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. |
EventType | String | The event type. |
VideoId | String | The video ID. |
Status | String | The processing status. Valid values:
|
Extend | String | When you call an upload or job submission API operation, you can specify the UserData parameter. If this parameter contains the Extend field, the custom user data is passed through and returned in the event completion callback. The maximum length is 512 bytes. |
Callback validation and retries
HTTP callbacks
When ApsaraVideo VOD sends an HTTP callback, the callback is considered successful if the receiving service responds with an HTTP status code of 200. The callback is considered failed if the status code is not 200 or if the response times out after 5 seconds. ApsaraVideo VOD ignores the response body and relies only on the HTTP status code.
If a callback fails due to a configuration error, such as an incorrect webhook address or an abnormal receiving service, ApsaraVideo VOD retries the callback two more times for a maximum of three attempts. After three failed attempts, the message is discarded.
Simple Message Queue (formerly MNS) callbacks
When ApsaraVideo VOD sends a Simple Message Queue (formerly MNS) callback, the callback is considered successful if the message is written to the Simple Message Queue (formerly MNS) queue. Otherwise, the callback is considered failed.
If writing the message to the Simple Message Queue (formerly MNS) queue fails due to a configuration error, ApsaraVideo VOD retries two more times for a maximum of three attempts. Examples of configuration errors include not granting access permissions to ApsaraVideo VOD, using a queue address that is not on the internet, or using an incorrect queue name. After three failed attempts, the message is discarded.
After a callback fails, ApsaraVideo VOD retries after a 1 second interval. If the callback still fails after three total attempts, the message is discarded. To ensure reliable notifications, use Simple Message Queue (formerly MNS) callbacks. They offer higher reliability and almost always succeed if configured properly.
Callback configuration
The configuration procedures for HTTP and MNS callbacks are different. You can configure both in the ApsaraVideo VOD console or using the API/SDK. For more information about the procedures and limits, see How to use HTTP callbacks and How to use MNS callbacks.
Event types
ApsaraVideo VOD supports the following event notification types:
Event type | Reference |
FileUploadComplete | |
ImageUploadComplete | |
StreamTranscodeComplete | |
TranscodeComplete | |
SnapshotComplete | |
DynamicImageComplete | |
AddLiveRecordVideoComplete | |
LiveRecordVideoComposeStart | |
UploadByURLComplete | |
UploadByURLComplete | |
CreateAuditComplete | |
VideoAnalysisComplete | |
UpdateMediaStorageClassComplete | |
RestoreMediaComplete | |
AttachedMediaUploadComplete | |
ProduceMediaComplete | |
DeleteMediaComplete | |
MediaBaseChangeComplete | |
SubmitMediaRefreshComplete | |
WorkflowTaskComplete | Workflow task completed |
FAQ
If you encounter problems, such as how to obtain HTTPS URLs from callbacks or how to implement multiple webhook addresses, see the FAQ about event notifications.