Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Simple Message Notification/ Getting Started/ Publishing a JSON Message Using SMN

Publishing a JSON Message Using SMN

Updated on 2024-09-30 GMT+08:00

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

Making Preparations

Sign up for a HUAWEI ID, complete real-name authentication, enable Huawei Cloud services, and top up your account.

Step 1: Create a Topic

Create a topic Mytopic.

Step 2: Add a Subscription

Add SMS and email subscriptions to the topic.

Step 3: Publish a Message

  • Publish a message "Dear Sir or Madam, this is an SMS message." to the SMS subscriber.
  • Publish a message "Dear Sir or Madam, this is an Email message." to the email subscriber.

Step 4: Receive the Message

The subscription endpoints receive the messages.

Making Preparations

  1. 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.

  2. Top up your account.

    Ensure that the account balance is sufficient. If not, top up your account.

Step 1: Create a Topic

  1. Log in to the SMN console and go to the Create Topic page.
  2. 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.

  3. 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.

Step 2: Add a Subscription

Add SMS and email subscriptions to the topic.

  1. In the topic list, locate Mytopic and click Add Subscription in the Operation column.
  2. 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.
  3. 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.

  1. In the topic list, locate Mytopic and click Add Subscription in the Operation column.
  2. 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.
  3. 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.

  1. In the topic list, locate Mytopic and click Add Subscription in the Operation column.
  2. 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.
  3. 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.

  1. In the topic list, locate Mytopic and click Add Subscription in the Operation column.
  2. 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.
  3. 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

  1. In the topic list, locate Mytopic and click Publish Message in the Operation column.
  2. 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.

  3. Click OK.

    For details about messages, see Messages Using Different Protocols.

Step 4: Receive the Message

Subscription endpoints of different protocols receive different messages.

  • SMS

    SMS messages only contain the message content.

  • Email

    Email messages contain the message subject, content, and a link to unsubscribe.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback