System Subscriptions
Scenario
IEF provides the system subscription function for you to subscribe to IEF resource change events. When a resource is created, updated, or deleted, IEF will send a message to the specified API Gateway endpoint so that you can obtain resource changes in a timely manner.
System subscription is the special implementation of edge-cloud messages. IEF sends event messages about specific resources to a specified topic and calls an API of API Gateway to notify you of resource changes.
Events That Can Be Subscribed To
You can subscribe to the following events from IEF.
System Event |
Topic |
Resource Type |
Operation |
---|---|---|---|
Instance creation |
$hw/events/instance/+/created |
Application instance |
Create |
Instance update |
$hw/events/instance/+/updated |
Application instance |
Update |
Instance deletion |
$hw/events/instance/+/deleted |
Application instance |
Delete |
Application deletion |
$hw/events/deployment/+/deleted |
Containerized application |
Delete |
Application creation |
$hw/events/deployment/+/created |
Containerized application |
Create |
Application update |
$hw/events/deployment/+/updated |
Containerized application |
Update |
Node being brought online |
$hw/events/edgeNode/+/online |
Edge node |
Bring online |
Node being brought offline |
$hw/events/edgeNode/+/offline |
Edge node |
Bring offline |
System Subscription Process
The system subscription process is as follows:
- Create an API on API Gateway for IEF to call.
- Create an API Gateway endpoint on IEF.
- Create a system subscription on IEF.
Creating an API
Create an API on API Gateway. For details, see Getting Started.
This API is called by IEF to send system event messages.
Creating an API Gateway Endpoint
- Log in to the IEF console.
- In the navigation pane, choose Edge-Cloud Messages > Endpoints.
- Click Create Endpoint in the upper right corner, and set the endpoint parameters.
Figure 1 Creating an endpoint
- Type: Select API Gateway.
- Name: Enter an endpoint name.
- Click OK. The endpoint is successfully created and the endpoint list page is displayed.
Creating a System Subscription
- Log in to the IEF console.
- In the navigation pane, choose Edge-Cloud Messages > System Subscriptions.
- Click Create System Subscription in the upper right corner, and set the system subscription parameters.
Figure 2 Creating a system subscription
- Name: Enter a system subscription name.
System subscriptions and message routes are of the same resource type. Their names cannot conflict with each other.
- Topic: Select the resource and operation to be subscribed, for example, creating a containerized application. For details about the events that can be subscribed to, see Table 1.
- Destination Endpoint: Select the endpoint created in Creating an API Gateway Endpoint.
- Destination Endpoint Resource: Select the API created in Creating an API.
- Name: Enter a system subscription name.
- Click Create.
Message Forwarding After Subscription
After a system subscription is created, IEF will forward a message when a system event occurs. The statistics about message forwarding can be viewed on the System Subscriptions page of the IEF console.
Meanwhile, IEF will call the API registered on API Gateway. The request body is as follows: (The request body uses the standard CloudEvents format. For details, see CloudEvents.)
{ "data": { "event_type": "instance", "operation": "created", "timestamp": 134567677, "topic": "$hw/events/deployment/+/created", "name": "xxxx", "attributes": {"ID":"x"} }, "datacontenttype": "application/json", "source": "sysevents", "id": "xxxx", "time": "2020-11-5 xxx" }
- data: system event data.
- event_type: resource type. The value is a character string.
- operation: operation performed on the resource. The value is a character string.
- topic: topic to which a message is sent. The value is a character string.
- timestamp: time when an event occurs. The value is of the UInt64 type.
- name: resource name. The value is a character string.
- attributes: resource attributes. This parameter is not contained in the request for deleting a resource. The value is of the Object type.
- datacontenttype: format of the system event data content. The value is a character string.
- source: source of the system event. The value is a character string.
- id: system event ID, which is a character string.
- time: time when the system event occurs. The value is a character string.
Table 1 lists the resource types, operations, and topics supported by IEF.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot