tencent cloud

All product documents
Batch Compute
Event Notice & Callback
Last updated: 2024-01-13 11:19:29
Event Notice & Callback
Last updated: 2024-01-13 11:19:29

Summary

BatchCompute (Batch) supports throwing of events generated in the jobs and compute environment in the form of Cloud Message Queue (CMQ). For example, when events such as job execution success/failure and compute environment node creation success/failure/exception occur, notifications and callbacks can be made possible through the topic subscription mechanism of CMQ.

How to Use

A compute environment listening event is used as an example below to demonstrate how to register a compute environment-related event in three steps.

1. Create a CMQ topic

Log in to the CMQ Console and create a new topic.




2. Create a compute environment and associate the CMQ topic

Add a notifications field when submitting a job (SubmitJob) or creating a compute environment (Create) and specify the event_name of the event to be listened to. Multiple events can be specified.
"notifications": [
{
"event_configs": [
{
"event_name": "JobFailed" // Event name
},
{
"event_name": "JobSucceed",
"event_vars": [ // Custom event parameter
{
"name": "jobSucceed",
"value": "Success"
}
]
}
],
"topic_name": "job-message" // CMQ topic name
}
],
Currently, it is only supported to associate CMQ topics when creating a compute environment via API or CLI. Doing so in the console will be supported in the future.
event_vars: In addition to the fixed message generated by the event, custom parameters can be added.
topic_name: Name of the associated CMQ topic (Note: This is not the ID). All event messages will be delivered to this topic which will then forward the messages to all subscribers.

3. Set up a subscriber and test

Add a subscriber to the newly created topic in the CMQ Console. For quick and easy viewing, you can specify an existing message queue.


The message structure is as follows. If a message queue is specified as the subscriber, you can quickly view the messages sent to the topic by Batch in CMQ Console > Message Receiving where the message content requires Base64 processing.
{
"Events": [{
"EventVersion": "1.0",
"EventTime": "2018-06-15T14:43:17Z",
"Region": "ap-guangzhou",
"Batch": {
"ComputeNodeId": "node-0iy7wxyo",
"EnvId": "env-ptoxdb1t",
"ComputeNodeState": "CREATED",
"Mem": 8,
"ResourceCreatedTime": "2018-06-15T14:43:18Z",
"EnvName": "batch-env",
"ComputeNodeInstanceId": "ins-9rikj9kw",
"Cpu": 4
},
"EventName": "COMPUTE_NODE_CREATED",
"EventVars": []
}]
}

Job-related Events

Type
Description
JOB_RUNNING
Job is running
JOB_SUCCEED
Job succeeded
JOB_FAILED
Job failed
JOB_FAILED_INTERRUPTED
Job is interrupted due to failure
TASK_RUNNING
Task is running
TASK_SUCCEED
Task succeeded
TASK_FAILED
Task failed
TASK_FAILED_INTERRUPTED
Task is interrupted due to failure
TASK_INSTANCE_RUNNING
Task instance is running
TASK_INSTANCE_SUCCEED
Task instance succeeded
TASK_INSTANCE_FAILED
Task instance failed
TASK_INSTANCE_FAILED_INTERRUPTED
Task instance is interrupted due to failure
For more information, see SubmitJob.

Compute Environment-related Events

Type
Description
COMPUTE_ENV_CREATED
Compute environment created
COMPUTE_ENV_DELETED
Compute environment deleted
COMPUTE_NODE_CREATED
Compute node successfully created
COMPUTE_NODE_CREATION_FAILED
Compute node creation failed
COMPUTE_NODE_RUNNING
Compute node is running
COMPUTE_NODE_ABNORMAL
Compute node is abnormal
COMPUTE_NODE_DELETING
Deleting compute node
For more information, see CreateComputeEnv.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon