All Products
Search
Document Center

Notification

Last Updated: Nov 02, 2018

Batch Compute service sends notification messages based on the topics offered by MNS. You can create, manage, and subscribe to topics, and specify topic configuration when using Batch Compute to create a cluster or submit a job. Batch Compute then pushes messages to the specified topics based on the configuration. You can set four notification methods in the MNS console: URL, MNS queue, email, and SMS. Currently, Batch Compute supports two types of message events: cluster events and job events.

1. Preparations

  1. Activate the message service
  2. Create an MNS topic
  3. Create an MNS topic subscription
  4. Authorize Batch Compute message push.
  5. Log on to the console to complete one-key authorization. If you have not completed the authorization, the console displays the following message:

Console

Skip this step if you have completed the authorization.

2. Billing

The message service fee is settled by the message service, and no extra fee is charged for Batch Compute service.

3. Message types

3.1 Cluster events

When using the SDK or console to create a cluster, you can configure the following type of message events.

  1. {
  2. "Notification": {
  3. "Topic": {
  4. "Name": "test-topic",
  5. "Endpoint": "http://[UserId].mns.[Region].aliyuncs.com/",
  6. "Events": [
  7. "OnClusterDeleted",
  8. "OnInstanceCreated",
  9. "OnInstanceActive"
  10. ]
  11. }
  12. }
  13. }
Field Description
Name Name of an MNS topic
Endpoint MNS intranet endpoin. For more information, see Get Endpoint.

3.2 Job events

When using the SDK or console to create a job, you can configure the following type of message events.

  1. {
  2. "Notification": {
  3. "Topic": {
  4. "Name": "test-topic",
  5. "Endpoint": "http://[UserId].mns.[Region].aliyuncs.com/",
  6. "Events": [
  7. "OnJobWaiting",
  8. "OnJobRunning",
  9. "OnJobStopped",
  10. "OnJobFinished",
  11. "OnJobFailed",
  12. "OnTaskWaiting",
  13. "OnTaskRunning",
  14. "OnTaskStopped",
  15. "OnTaskFinished",
  16. "OnTaskFailed",
  17. "OnInstanceWaiting",
  18. "OnInstanceRunning",
  19. "OnInstanceStopped",
  20. "OnInstanceFinished",
  21. "OnInstanceFailed",
  22. "OnPriorityChange"
  23. ]
  24. }
  25. }
  26. }
Field Description
Name Name of an MNS topic
Endpoint MNS intranet endpoint. For more information, see Get Endpoint.

4. Message format

Currently, messages are sent in JSON string format.

4.1 Cluster events

Message for an OnClusterDeleted event.

  1. {
  2. "Category": "Cluster",
  3. "ClusterId": "cls-hr2rbl6qt5gki7392b8001",
  4. "ClusterName": "test-cluster",
  5. "CreationTime": "2016-11-01T15:25:02.837728Z",
  6. "State": "Deleted",
  7. "Event": "OnClusterDeleted"
  8. }

Message for an OnInstanceCreated or OnInstanceActive event.

  1. {
  2. "Category": "Cluster",
  3. "ClusterId": "cls-hr2rbl6qt5gki7392b8001",
  4. "Group": "group1",
  5. "InstanceId": "i-wz9c51g2s6zsrtnqi4fa",
  6. "InnerIpAddress": "10.45.168.26",
  7. "Hints": "",
  8. "State": "Starting",
  9. "CreationTime": "2016-11-01T15:25:02.837728Z",
  10. "Event": "OnInstanceCreated"
  11. }

4.2 Job events

Message for an OnJobWaiting, OnJobRunning, OnJobStopped, OnJobFinished, or OnJobFailed event.

  1. {
  2. "Category": "Job",
  3. "JobId": "job-0000000058524720000077E900007257",
  4. "JobName": "test-job",
  5. "Event": "OnJobWaiting",
  6. "State": "Waiting",
  7. "CreationTime": "2016-11-01T15:25:02.837728Z",
  8. "StartTime": "2016-11-01T15:35:02.837728Z",
  9. "EndTime": "2016-11-01T15:45:02.837728Z",
  10. "Message": ""
  11. }

Message for an OnTaskWaiting, OnTaskRunning, OnTaskStopped,OnTaskFinished, or OnTaskFailed event

  1. {
  2. "Category": "Job",
  3. "JobId": "job-0000000058524720000077E900007257",
  4. "Task": "Echo",
  5. "Event": "OnTaskWaiting",
  6. "State": "Waiting",
  7. "StartTime": "2016-11-01T15:35:02.837728Z",
  8. "EndTime": "2016-11-01T15:45:02.837728Z"
  9. }

Message for an OnInstanceWaiting, OnInstanceRunning, or OnInstanceStopped eventOnInstanceFinished/OnInstanceFailed.

  1. {
  2. "Category": "Job",
  3. "JobId": "job-0000000058524720000077E900007257",
  4. "Task": "Echo",
  5. "InstanceId": "0",
  6. "Event": "OnInstanceWaiting",
  7. "State": "Waiting",
  8. "StartTime": "2016-11-01T15:35:02.837728Z",
  9. "EndTime": "2016-11-01T15:45:02.837728Z",
  10. "RetryCount": "0",
  11. "Progress": "0",
  12. "StdoutRedirectPath": "oss://bucket/tests/a44c0ad8-a003-11e6-8f8e-fefec0a80e06/logs/stderr.job-0000000058184218000008150000000D.task.0",
  13. "StderrRedirectPath": "oss://bucket/tests/a44c0ad8-a003-11e6-8f8e-fefec0a80e06/logs/stdout.job-0000000058184218000008150000000D.task.0",
  14. "ExitCode": "0",
  15. "ErrorCode": "",
  16. "ErrorMessage": "",
  17. "Detail": ""
  18. }

Message for an OnPriorityChange event.

  1. {
  2. "Category": "Job",
  3. "JobId": "job-0000000058524720000077E900007257",
  4. "JobName": "test-job",
  5. "Event": "OnPriorityChange",
  6. "State": "Waiting",
  7. "CreationTime": "2016-11-01T15:45:02.837728Z",
  8. "StartTime": "2016-11-01T15:55:02.837728Z",
  9. "EndTime": "2016-11-01T15:57:02.837728Z",
  10. "Message": "",
  11. "From": "10",
  12. "To": "20"
  13. }