Após o envio, receba a notificação na fila ou no tópico especificado do Simple Message Queue (SMQ). Este tópico descreve como receber essas notificações.
Preparações
O recurso de notificação está ativado. Para mais informações, consulte Defina as notificações.
Receber notificações em uma fila MNS
-
Use o MNS SDK for Java para receber notificações. Para mais informações, consulte Gerencie filas.
NotaEste exemplo usa o MNS SDK for Java. Para saber como usar SDKs do MNS em outras linguagens e receber notificações, consulte Baixe e use SDKs.
Use o console do MNS para receber notificações. Para mais informações, consulte Get started with queue-based messaging.
Receber notificações em um tópico MNS
-
Use o MNS SDK for Java para receber notificações. Para mais informações, consulte Gerencie tópicos.
NotaEste exemplo usa o MNS SDK for Java. Para saber como usar SDKs do MNS em outras linguagens e receber notificações, consulte Baixe e use SDKs.
Use o console do MNS para receber notificações. Para mais informações, consulte Get started with topic-based messaging.
Formato de mensagem para um job
Parâmetro | Descrição |
jobId(JobId) | ID do job. |
requestId(RequestId) | ID da solicitação. |
type(Type) | Tipo do job. Valores válidos:
|
state(State) | Status do job. Valores válidos:
|
code | Código de erro retornado se o job falhar. |
msg | Mensagem de erro retornada se o job falhar. |
UrlPattern | URL do snapshot com placeholders. Este valor serve como modelo de URL. Nota Retornado quando type(Type) é Snapshot e os snapshots ocorrem em momentos específicos. |
LastUrl | URL do último snapshot. Nota Retornado quando type(Type) é Snapshot e os snapshots ocorrem em momentos específicos. |
Count | Número total de snapshots. Nota Retornado quando type(Type) é Snapshot e os snapshots ocorrem em momentos específicos. |
TimeArray | Momento da captura do snapshot. Nota Retornado quando type(Type) é Snapshot e os snapshots ocorrem em momentos específicos. |
Exemplo de callback de sucesso
{
"jobId": "8f91f1b630f3469eb5ecf445028f****",
"JobId": "8f91f1b630f3469eb5ecf445028f****",
"Type": "Snapshot",
"userData": "{}",
"UserData": "{}",
"State": "Success",
"state": "Success",
"type": "Snapshot",
"LastUrl": "http://example.oss-cn-shanghai.aliyuncs.com/example_output/2021-11-14/V4/Async-V2-00005.jpg",
"TimeArray": [10050, 50000, 110000, 1000500, 1100500],
"UrlPattern": "http://eaxmple.oss-cn-shanghai.aliyuncs.com/example_output/2021-11-14/V4/Async-V2-{Count}.jpg",
"Count": 5
}
Exemplo de callback de falha
{
"msg": "TimeArray greater than video duration.",
"Msg": "TimeArray greater than video duration.",
"code": "InvalidParameter.TimeArray",
"userData": "{}",
"UserData": "{}",
"type": "Snapshot",
"Code": "InvalidParameter.TimeArray",
"jobId": "f8abc5d9dee0425fa26bb9946df1****",
"Type": "Snapshot",
"State": "Fail",
"UrlPattern": "http://example.oss-cn-shanghai.aliyuncs.com/example_output/2023-11-15/regression_test/TimePoint/V1/Async-V1-{Count}.jpg",
"TimeArray": [10050, 50000, 110000, 1000500, 1100500, 1800000],
"state": "Fail",
"JobId": "f8abc5d9dee0425fa26bb9946df1****"
}
Formato de mensagem para um workflow
A mensagem de notificação de um workflow de mídia usa o formato JSON. Para obter detalhes sobre os parâmetros, consulte a descrição das mensagens de workflow de mídia no tópico Add a media file.
Estrutura da mensagem:
-
Início
O
activity typenosbasic attributes of the activityéStart. -
Estrutura
O código a seguir mostra a estrutura.
-
Relatório
O
activity typenosbasic attributes of the activityéReport. -
Código de exemplo
{ // 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", } }