El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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/ Distributed Message Service for RabbitMQ/ Getting Started/ Getting Started with RabbitMQ for Message Production and Consumption

Getting Started with RabbitMQ for Message Production and Consumption

Updated on 2025-01-21 GMT+08:00

This section takes an example to get you started with DMS for RabbitMQ. The example creates a RabbitMQ instance with SSL disabled, and accesses it over a private network on a client within a VPC. As a result, messages can be produced and consumed.

Figure 1 Procedure for using DMS for RabbitMQ
  1. Step 1: Preparations

    A RabbitMQ instance runs in a Virtual Private Cloud (VPC). Before creating a RabbitMQ instance, ensure that a VPC is available.

  2. Step 2: Creating a RabbitMQ Instance

    You can select the specifications and quantity when creating a RabbitMQ instance.

  3. Step 3: Accessing an Instance for Message Production and Consumption

    A client connects to the instance with SSL disabled using the demo provided by RabbitMQ.

Step 1: Preparations

  1. Register a HUAWEI ID.

    Before creating a RabbitMQ instance, register a HUAWEI ID. For details, see Signing Up for a HUAWEI ID and Enabling Huawei Cloud Services.

    If you already have a HUAWEI ID, skip this step.

  2. Grant RabbitMQ instance permissions.

    To achieve fine-grained management of your cloud resources, create Identity and Access Management (IAM) user groups and users and grant specified permissions to the users. For more information, see Creating a User and Granting DMS for RabbitMQ Permissions.

  3. Create a VPC and subnet.

    Before creating a RabbitMQ instance, ensure that a VPC and a subnet are available. For details about how to create a VPC and subnet, see Creating a VPC and Subnet.

    The VPC must be created in the same region as the RabbitMQ instance.

  4. Create a security group and add security group rules.

    Before creating a RabbitMQ instance, ensure that a security group is available. For details about how to create a security group, see Creating a Security Group.

    The security group must be created in the same region as the RabbitMQ instance.

    To connect to RabbitMQ instances, add the security group rules described in Table 1. Other rules can be added based on site requirements.
    Table 1 Security group rules

    Direction

    Protocol

    Port

    Source address

    Description

    Inbound

    TCP

    5672

    0.0.0.0/0

    Accessing a RabbitMQ instance (SSL disabled)

    NOTE:

    After a security group is created, it has a default inbound rule that allows communication among ECSs within the security group and a default outbound rule that allows all outbound traffic. If you access your RabbitMQ instance over a private network within a VPC, you do not need to add the rules described in Table 1.

  5. Construct a client for message production and consumption.

    This section uses a Linux elastic cloud server (ECS) as the client. Before creating a RabbitMQ instance, create an ECS with elastic IPs (EIPs), install JDK, and configure the environment variables.
    1. Log in to the console, click in the upper left corner, click Elastic Cloud Server under Computing, and then create an ECS.

      For details about how to create an ECS, see Purchasing a Custom ECS. If you already have an available ECS, skip this step.

    2. Log in to an ECS as user root.
    3. Install Java JDK and configure the environment variables JAVA_HOME and PATH.
      1. Download a JDK.
        NOTE:

        Use Oracle JDK instead of ECS's default JDK (for example, OpenJDK), because ECS's default JDK may not be suitable. Obtain Oracle JDK 1.8.111 or later from Oracle's official website.

      2. Decompress the JDK.
        tar -zxvf jdk-8u321-linux-x64.tar.gz

        Change jdk-8u321-linux-x64.tar.gz to your JDK version.

      3. Open the .bash_profile file.
        vim ~/.bash_profile
      4. Add the following content:
        export JAVA_HOME=/opt/java/jdk1.8.0_321 
        export PATH=$JAVA_HOME/bin:$PATH

        Change /opt/java/jdk1.8.0_321 to the path where you install JDK.

      5. Press Esc. Enter the following line and press Enter. Save the .bash_profile file and exit.
        :wq
      6. Run the following command to make the change take effect:
        source .bash_profile
      7. Check whether the JDK is installed.
        java -version
        If the following message is returned, the JDK is installed.
        java version "1.8.0_321"

Step 2: Creating a RabbitMQ Instance

  1. Go to the Buy Instance page.
  2. On the Quick Config tab page, set basic instance configurations shown in Figure 2. Table 2 lists the configuration details.

    Table 2 Setting basic instance configurations

    Parameter

    Description

    Billing Mode

    Select Pay-per-use, which is a postpaid mode. You can pay after using the service, and will be billed for your usage duration. The fees are calculated in seconds and settled by hour.

    Region

    DMS for RabbitMQ in different regions cannot communicate with each other over an intranet. Select a nearest location for low latency and fast access.

    Select AP-Singapore.

    AZ

    An AZ is a physical region where resources use independent power supply and networks. AZs are physically isolated but interconnected through an internal network.

    Select AZ1.

    Figure 2 Setting basic instance configurations

  3. Set the instance specifications and storage space, as shown in Figure 3. For details, see Table 3.

    Table 3 Setting the instance specifications and storage space

    Parameter

    Description

    Bundle

    Select Test: Single-node instances with mini specs, saving resources and costs for testing or debugging. Note that high availability is unavailable.

    Storage Space per Broker

    Select the disk type and specify the disk size as required.

    Total storage space = Storage space per broker × Broker quantity. The disk type cannot be changed once the instance is created.

    Select Ultra-high I/O and enter 100.

    Figure 3 Setting the instance specifications and storage space

  4. Configure the instance network as shown in Figure 4. For details, see Table 4.

    Table 4 Configuring instance network

    Parameter

    Description

    VPC

    After the RabbitMQ instance is created, its VPC cannot be changed.

    Select the VPC prepared in 3.

    Subnet

    After the RabbitMQ instance is created, its subnet cannot be changed.

    Select the subnet prepared in 3.

    Security Group

    Select the security group prepared in 4.

    Figure 4 Configuring instance network

  5. Set the instance access mode. Retain the default setting.
  6. Set the instance authentication method as shown in Figure 5. For details, see Table 5.

    Table 5 Configuring the instance authentication method

    Parameter

    Description

    RabbitMQ Authentication Username

    Enter the username used for accessing the instance.

    A username should contain 4 to 64 characters, start with a letter, and contain only letters, digits, hyphens (-), and underscores (_).

    Enter "test".

    Password

    Enter the password used for accessing the instance.

    A password must meet the following requirements:

    • Contains 8 to 32 characters.
    • Contains at least three types of the following characters: uppercase letters, lowercase letters, digits, and special characters `~!@#$%^&*()-_=+\|[{}];:'",<.>? and spaces, and cannot start with a hyphen (-).
    • Cannot be the username spelled forwards or backwards.
    Figure 5 Configuring the instance authentication method

  7. Configure Advanced Settings, as shown in Figure 6. For details, see Table 6. Retain default settings for other parameters.

    Table 6 Configuring instance advanced settings

    Parameter

    Description

    Instance Name

    You can customize a name that complies with the rules: 4–64 characters; starts with a letter; can contain only letters, digits, hyphens (-), and underscores (_).

    Enter "rabbitmq-test".

    Enterprise Project

    This parameter is for enterprise users. An enterprise project manages project resources in groups. Enterprise projects are logically isolated.

    Select default.

    Figure 6 Configuring instance advanced settings

  8. Click Confirm.
  9. Confirm the instance information, read and agree to the Huawei Cloud Customer Agreement, and then submit the request.
  10. Return to the instance list and check whether the instance has been created.

    It takes 3 to 15 minutes to create an instance. During this period, the instance status is Creating.
    • If the instance is created successfully, its status changes to Running.
    • If the instance is in the Creation failed state, delete it and try purchasing another one. If the instance purchase fails again, contact customer service.

  11. After the instance is created, click its name to go to the instance details page.
  12. In the Connection area, view and record the connection address.

    Figure 7 Connection address

Step 3: Accessing an Instance for Message Production and Consumption

  1. Go to the root directory on the ECS and download the sample project code RabbitMQ-Tutorial.zip.

    wget https://dms-demo.obs.cn-north-1.myhuaweicloud.com/RabbitMQ-Tutorial.zip
    NOTE:

    /root is the path for storing the sample project code. Change it to the actual path if needed.

  2. Run the following command to decompress RabbitMQ-Tutorial.zip:

    unzip RabbitMQ-Tutorial.zip

  3. Run the following command to navigate to the RabbitMQ-Tutorial directory, which contains the precompiled JAR file:

    cd RabbitMQ-Tutorial

  4. Produce messages using the sample project.

    java -cp .:rabbitmq-tutorial.jar Send ${host} ${port} ${user} ${password}

    Description:

    Sample message production:

    [root@ecs-test RabbitMQ-Tutorial]# java -cp .:rabbitmq-tutorial.jar Send 192.168.xx.40 5672 test Zxxxxxxs
     [x] Sent 'Hello World!'
    [root@ecs-test RabbitMQ-Tutorial]# java -cp .:rabbitmq-tutorial.jar Send 192.168.xx.40 5672 test Zxxxxxxs
     [x] Sent 'Hello World!'

  5. Consume messages using the sample project.

    java -cp .:rabbitmq-tutorial.jar Recv ${host} ${port} ${user} ${password}

    Description:

    Sample message consumption:

    [root@ecs-test RabbitMQ-Tutorial]# java -cp .:rabbitmq-tutorial.jar Recv 192.168.xx.40 5672 test Zxxxxxxs
     [*] Waiting for messages. To exit press CTRL+C
     [x] Received 'Hello World!'
     [x] Received 'Hello World!'

    Press Ctrl+C to cancel.

Related Information

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback