Publishing a JSON Message Using SMN
Scenarios
You can publish a JSON message to an SMN topic to broadcast the message to different types of subscription endpoints in the topic.
To start your experience with SMN, this topic describes how to create a topic and publish a JSON message.
Operation Process
Procedure |
Description |
---|---|
Sign up for a HUAWEI ID, complete real-name authentication, enable Huawei Cloud services, and top up your account. |
|
Create a topic Mytopic. |
|
Add SMS and email subscriptions to the topic. |
|
|
|
The subscription endpoints receive the messages. |
Making Preparations
- Sign up for Huawei Cloud and complete real-name authentication.
Before using SMN, sign up for a HUAWEI ID, enable Huawei Cloud services, and complete real-name authentication.
If you have enabled Huawei Cloud services and completed real-name authentication, skip this step.
- Top up your account.
Ensure that the account balance is sufficient. If not, top up your account.
Step 1: Create a Topic
- Log in to the SMN console and go to the Create Topic page.
- Configure topic parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Creating a Topic.Figure 1 Create Topic
Table 1 Parameters for creating a topic Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic to be created.
Enterprise Project
default
This parameter is displayed only for enterprise users who have enabled enterprise project management.
- Click OK.
After a topic is created, the system generates a topic URN, which uniquely identifies the topic and cannot be changed. The topic you created is displayed in the topic list.
- In the topic list, locate Mytopic and click Add Subscription in the Operation column.
- Configure subscription parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Creating a Topic.
Figure 2 Add Subscription
Table 2 Parameters for adding an SMS subscription Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic you select to add subscriptions.
Protocol
SMS
Select SMS from the Protocol drop-down list.
For more supported protocols, see What Protocols Does SMN Support?
Endpoint
+8618612345678
Enter a valid mobile number in the text box.
- You can enter up to 10 endpoints, each on a separate line.
- SMN does not check whether subscription endpoints exist when you add subscriptions.
- Click OK.
After a subscription is added, the subscription endpoint receives a confirmation message. The recipient needs to click the subscription confirmation link on the subscription endpoint to confirm that they agree to receive messages published to the topic. On the SMN console, you can see that the subscription status is Confirmed.
- In the topic list, locate Mytopic and click Add Subscription in the Operation column.
- Configure subscription parameters.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Creating a Topic.
Figure 3 Add Subscription
Table 3 Parameters for adding an email subscription Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic you select to add subscriptions.
Protocol
Email
Select Email from the Protocol drop-down list.
For more supported protocols, see What Protocols Does SMN Support?
Endpoint
username@example.com
Enter a valid email address in the text box.
- You can enter up to 10 endpoints, each on a separate line.
- SMN does not check whether subscription endpoints exist when you add subscriptions.
- Click OK.
After a subscription is added, the subscription endpoint receives a confirmation message. The recipient needs to click the subscription confirmation link on the subscription endpoint to confirm that they agree to receive messages published to the topic. On the SMN console, you can see that the subscription status is Confirmed.
Step 3: Publish a Message
- In the topic list, locate Mytopic and click Publish Message in the Operation column.
- Configure parameters for publishing a message.
In this example, only some parameters are described. Retain the default values for other parameters. For details about the parameters, see Publishing a JSON Message.Figure 4 Publish Message
Table 4 Parameters for publishing a message Parameter
Example Value
Description
Topic Name
Mytopic
Specifies the name of the topic you select to publish a message.
Message Format
JSON
Specifies in which format messages will be sent.
Message
{ "default": "Dear Sir or Madam, this is a default message.", "sms": "Dear Sir or Madam, this is an SMS message.", "email": "Dear Sir or Madam, this is an Email message." }
You can manually enter a message in JSON format or click Generate JSON Message to automatically generate a message.
For details, see JSON Message Format.
- Click OK.
For details about messages, see Messages Using Different Protocols.
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