Publishing a JSON Message
Scenarios
In a JSON message, you can specify different message content for different protocols, including SMS, email, FunctionGraph (function), HTTP, and HTTPS.
Prerequisites
Subscribers in the topic must have confirmed the subscription, or they will not be able to receive any messages.
Procedure
- Log in to the management console.
- In the upper left corner of the page, click and select the desired region and project.
- Click . Select Simple Message Notification under Management & Governance.
The SMN console is displayed.
- In the navigation pane on the left, choose Topic Management > Topics.
The Topics page is displayed.
- In the topic list, locate the topic that you need to publish a message to and click Publish Message in the Operation column.
Alternatively, locate the topic and click its name. In the upper right corner of the displayed topic details page, click Publish Message.
- Configure parameters by referring to Table 1.
Table 1 Parameters required for publishing a message Parameter
Description
Subject
(Optional) Specifies the message subject, which must be fewer than 512 bytes.
Message Format
Specifies in which format a message is published. You can select only one message format each time you publish a message.
- Text: common text message
- JSON: JSON message
- Template: template message. For details, see Message Template Management.
Message
Specifies the message content. The message content cannot be left blank and its size cannot exceed 256 KB.
Select JSON for Message Format. Then, manually type the JSON message in the Message box or click Generate JSON Message to generate it automatically.
- If you choose to manually type the JSON message, see JSON Message Format.
- If you choose to automatically generate the JSON message, proceed with steps 7 through 10.
- Click Generate JSON Message.
- Enter your message content, for example, This is a default message., in the Message box and select the desired message protocols.
The size of a JSON message varies depending on the protocol combinations. As you type in the message content, the system will calculate the number of bytes you have entered, the size of the JSON message, and how many bytes are left. The total size of a JSON message includes braces, quotation marks, spaces, line breaks, and message content. For details about how to calculate the size of a JSON message, see Calculation on the Size of a JSON Message in JSON Message Format.
Figure 1 Generate JSON Message
- Click OK.
Figure 2 JSON message
- Modify the message content for each protocol so that different messages are sent to endpoints of different protocols. The system generates JSON-formatted content that includes a default message and content for each protocol. When SMN fails to match any specific message protocol, it sends the default message. For detailed, see JSON Message Format.
- (Optional) Configure message attribute parameters. Message attributes specify the scope of message publishing.
Table 2 Message attribute parameters Parameter
Description
Type
Select the type of the message to be published.
- Protocol
- String Array
- String
Name
Enter up to 32 characters, including only digits, lowercase letters, and underscores (_). Start with a number or lowercase letter. Do not end with an underscore (_) or enter consecutive underscores (_).
- When you set Type to Protocol, Name is smn_protocol by default.
- If you set Type to String array, enter the name of the array that restricts the message to be published.
- When you set Type to String, enter the name of the character string that restricts the message to be published.
Value
- When you set Type to Protocol, select a protocol from the drop-down list. The available options are SMS, Email, HTTP, HTTPS, FunctionGraph (function), and functionGraph (workflow).
- When you set Type to String array, enter a string array. Length: 1 to 10
- When you set Type to String, you cannot leave Value blank. Enter up to 32 characters, including only digits, letters, and underscores (_).
- Click OK.
SMN delivers your message to all subscription endpoints. For details about the messages received by each endpoint, 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