ApsaraVideo VOD provides the callback feature. You can configure the UserData parameter when you use the ApsaraVideo VOD API or SDK to specify multiple HTTP or Simple Message Queue (formerly MNS) callback URLs. This feature can be used when you want to send event notifications of a specific type to multiple servers for further processing or send callback messages to multiple environments such as development, testing, and production. This topic describes how to specify multiple callback URLs.
Description
ApsaraVideo VOD allows you to configure only one callback method and callback URL for each region. The callback setting takes effect globally. ApsaraVideo VOD provides the UserData parameter that allows you to specify multiple callback URLs for muti-environment services.
Configure global event notifications
Limits
If you want to use Simple Message Queue (formerly MNS) callbacks, you must go to the Cloud Resource Access Authorization page to authorize ApsaraVideo VOD to access Simple Message Queue (formerly MNS).
Usage notes
ApsaraVideo VOD supports HTTP callbacks and Simple Message Queue (formerly MNS) callbacks for global event notifications. ApsaraVideo VOD is available in multiple regions and you can configure only one callback method and one callback URL for each region. This way, when events are triggered, ApsaraVideo VOD sends event notifications based on the callback setting that you specified for the region. You can perform the following operations to trigger the events: upload audio, video, or image files, or submit media processing jobs, such as transcoding jobs and review jobs.
Configuration method
You can configure global event notifications by using the ApsaraVideo VOD console, SDK, or API. For more information about the procedure and limits, see HTTP callbacks and SMQ callbacks.
Specify callback URLs in UserData during upload
Limits
You can specify the UserData parameter only by using the ApsaraVideo VOD SDK or API.
You must enable the global notification feature and specify the events for which you want to configure callbacks. Otherwise, the callback URLs that you specify in UserData do not take effect.
Usage notes
You can specify callback URLs in UserData for media files that are uploaded to ApsaraVideo VOD by using the server operation SDK or upload SDK. The callback URL that you specified is bound to the media source file. In this case, event notifications are sent to the callback URL when you submit media processing jobs such as transcoding jobs and review jobs for the media file. The events for which callbacks are configured are specified in the global callback settings. If you delete the media resource file, subsequent event notifications are sent to the callback URL that is specified in the global callback settings.
Related operations
For more information about how to use the server operation SDK or upload SDK, see Usage notes and Overview.
You can specify the UserData parameter when you call the following operations to upload media files:
Specify callback URLs in UserData during media processing
Limits
You can specify the UserData parameter only by using the ApsaraVideo VOD SDK or API.
You must enable the global notification feature and specify the events for which you want to configure callbacks. Otherwise, the callback URLs that you specify in UserData do not take effect.
Usage notes
You can specify callback URLs in UserData when you submit media processing jobs such as transcoding jobs by using the ApsaraVideo VOD SDK or API.
The callback URL that you specify in UserData during media processing takes effect only for a single event. If you do not specify callback URLs during media processing, the callback URLs that you specified in UserData during upload are preferentially used before the callback URLs specified in the global callback settings are used.
Related operations
You can specify the UserData parameter when you call the following operations to submit media processing jobs:
Sample code
For more information about the structure and details of the UserData parameter, see Request parameters. The following sample code provides an example on the structure of UserData:
{
"Extend":{
"width":1280,
"id":"028a8e56b*****1ebf6bb7afc74",
"height":720
},
"AccelerateConfig":{
"Type":"oss",
"Domain":"https://oss-accelerate.aliyuncs.com"
},
"MessageCallback":{
"CallbackURL":"https://xxxxx.com/2016-08-15/proxy/httpcallback/testcallback/",
"CallbackType":"http"
}
}
The following sample code provides an example on how to build UserData:
public static String buildUserData() {
JSONObject userData = new JSONObject();
// Configure message callbacks.
JSONObject messageCallback = new JSONObject();
messageCallback.put("CallbackType", "http");
messageCallback.put("CallbackURL", "https://xxxxx.com/2016-08-15/proxy/httpcallback/testcallback/");
userData.put("MessageCallback", messageCallback);
// The fields that you want to pass to UserData. You can pass custom parameters.
JSONObject extend = new JSONObject();
extend.put("id", "028a8e56b*****1ebf6bb7afc74");
extend.put("width", 1280);
extend.put("height", 720);
userData.put("Extend", extend);
// Configure upload acceleration if the acceleration service is needed. Before you can use upload acceleration, apply to enable the acceleration feature.
JSONObject accelerateConfig = new JSONObject();
accelerateConfig.put("Type", "oss");
accelerateConfig.put("Domain", "https://oss-accelerate.aliyuncs.com");
userData.put("AccelerateConfig", accelerateConfig);
return userData.toJSONString();
}