- What's New
- Function Overview
- Product Bulletin
-
Service Overview
- Infographics
- What Is DMS for RabbitMQ?
- Product Advantages
- Application Scenarios
- Specifications
- Comparing RabbitMQ, Kafka, and RocketMQ
- Comparing RabbitMQ AMQP-0-9-1 with Open-Source RabbitMQ
- Comparing RabbitMQ Versions
- Related Services
- Security
- Notes and Constraints
- Basic Concepts
- Exchanges
- Permissions Management
- Billing
- Getting Started
-
User Guide
- Process of Using RabbitMQ
- Permissions Management
- Buying a RabbitMQ Instance
- Configuring Virtual Hosts
- Accessing a RabbitMQ Instance
- Managing Messages
- Advanced Features
-
Managing Instances
- Viewing and Modifying Basic Information of a RabbitMQ Instance
- Viewing RabbitMQ Client Connection Addresses
- Managing RabbitMQ Instance Tags
- Configuring RabbitMQ Recycling Policies
- Resetting the RabbitMQ Instance Password
- Enabling RabbitMQ Plug-ins
- Exporting the RabbitMQ Instance List
- Deleting a RabbitMQ Instance
- Logging In to RabbitMQ Management UI
- Modifying RabbitMQ Instance Specifications
- Migrating RabbitMQ Services
- Testing Instance Performance
- Applying for Increasing RabbitMQ Quotas
- Viewing Metrics and Configuring Alarms
- Viewing RabbitMQ Audit Logs
-
Best Practices
- RabbitMQ Best Practices
- Automatic Recovery of a RabbitMQ Client from Network Exceptions
- Automatic Consumer Reconnection After a RabbitMQ Node Restart
- Improving RabbitMQ Performance
- Configuring Queue Load Balancing
- Deduplicating Messages Through Message Idempotence
- Suggestions on Using DMS for RabbitMQ Securely
- Developer Guide
-
API Reference
- Before You Start
- API Overview
- Calling APIs
- Getting Started
- APIs V2 (Recommended)
- Permissions and Supported Actions
- Out-of-Date APIs
- Appendix
- Change History
- SDK Reference
-
FAQs
-
Instances
- What RabbitMQ Version Does DMS for RabbitMQ Use?
- What SSL Version Does DMS for RabbitMQ Use?
- Why Can't I View the Subnet and Security Group Information During Instance Creation?
- How Are Requests Evenly Distributed to Each VM of a Cluster RabbitMQ Instance?
- Do Queues Inside a Cluster RabbitMQ Instance Have Any Redundancy Backup?
- Does DMS for RabbitMQ Support Data Persistence? How Do I Perform Scheduled Data Backups?
- How Do I Obtain the Certificate After SSL Has Been Enabled?
- Can I Change the SSL Setting of a RabbitMQ Instance?
- Can RabbitMQ Instances Be Scaled Up?
- Does RabbitMQ Support Two-Way Authentication?
- Does DMS for RabbitMQ Support CPU and Memory Upgrades?
- How Do I Disable the RabbitMQ Management UI?
- Can I Change the AZ for an Instance?
- How Do I Obtain the Region ID?
- Why Can't I Select Two AZs?
- How to Change Single-node RabbitMQ Instances to Cluster Ones?
- Can I Change the VPC and Subnet After a RabbitMQ Instance Is Created?
-
Connections
- How Do I Configure a Security Group?
- Why Does a Client Fail to Connect to a RabbitMQ Instance?
- Does DMS for RabbitMQ Support Public Access?
- Does DMS for RabbitMQ Support Cross-Region Deployment?
- Do RabbitMQ Instances Support Cross-VPC Access?
- Do RabbitMQ Instances Support Cross-Subnet Access?
- What Should I Do If I Fail to Access a RabbitMQ Instance with SSL Encryption?
- Can I Access a RabbitMQ Instance Using DNAT?
- Why Can't I Open the Management Web UI?
- Can a Client Connect to Multiple Virtual Hosts of a RabbitMQ Instance?
- Why Does a RabbitMQ Cluster Have Only One Connection Address?
- Do RabbitMQ Instances Support the Ping Command?
- Messages
- Monitoring & Alarm
-
Instances
- Videos
-
More Documents
-
User Guide (ME-Abu Dhabi Region)
- Service Overview
- Getting Started
- Process of Using RabbitMQ
- Permissions Management
- Buying a RabbitMQ Instance
- Configuring Virtual Hosts
- Accessing a RabbitMQ Instance
- Managing Messages
- Advanced Features
-
Managing Instances
- Viewing and Modifying Basic Information of a RabbitMQ Instance
- Viewing RabbitMQ Client Connection Addresses
- Managing RabbitMQ Instance Tags
- Resetting the RabbitMQ Instance Password
- Enabling RabbitMQ Plug-ins
- Using the rabbitmq_tracing Plug-in
- Exporting the RabbitMQ Instance List
- Deleting a RabbitMQ Instance
- Logging In to RabbitMQ Management UI
- Modifying RabbitMQ Instance Specifications
- Migrating RabbitMQ Services
- Applying for Increasing RabbitMQ Quotas
- Viewing Metrics and Configuring Alarms
- Viewing RabbitMQ Audit Logs
-
FAQs
-
Instances
- What RabbitMQ Version Does DMS for RabbitMQ Use?
- What SSL Version Does DMS for RabbitMQ Use?
- Why Can't I View the Subnet and Security Group Information During Instance Creation?
- How Are Requests Evenly Distributed to Each VM of a Cluster RabbitMQ Instance?
- Do Queues Inside a Cluster RabbitMQ Instance Have Any Redundancy Backup?
- Does DMS for RabbitMQ Support Data Persistence? How Do I Perform Scheduled Data Backups?
- How Do I Obtain the Certificate After SSL Has Been Enabled?
- Can I Change the SSL Setting of a RabbitMQ Instance?
- Can RabbitMQ Instances Be Scaled Up?
- Does RabbitMQ Support Two-Way Authentication?
- Does DMS for RabbitMQ Support CPU and Memory Upgrades?
- How Do I Disable the RabbitMQ Management UI?
- Can I Change the AZ for an Instance?
- How Do I Obtain the Region ID?
- Why Can't I Select Two AZs?
- How to Change Single-node RabbitMQ Instances to Cluster Ones?
- Can I Change the VPC and Subnet After a RabbitMQ Instance Is Created?
-
Connections
- How Do I Configure a Security Group?
- Why Does a Client Fail to Connect to a RabbitMQ Instance?
- Does DMS for RabbitMQ Support Public Access?
- Does DMS for RabbitMQ Support Cross-Region Deployment?
- Do RabbitMQ Instances Support Cross-VPC Access?
- Do RabbitMQ Instances Support Cross-Subnet Access?
- What Should I Do If I Fail to Access a RabbitMQ Instance with SSL Encryption?
- Can I Access a RabbitMQ Instance Using DNAT?
- Why Can't I Open the Management Web UI?
- Can a Client Connect to Multiple Virtual Hosts of a RabbitMQ Instance?
- Why Does a RabbitMQ Cluster Have Only One Connection Address?
- Messages
- Monitoring & Alarm
-
Instances
- Change History
- API Reference (ME-Abu Dhabi Region)
-
User Guide (Kuala Lumpur Region)
- Service Overview
- Permissions Management
- Preparing the Environment
- Buying an Instance
- Accessing a RabbitMQ Instance
- Operating RabbitMQ Instances
- Quotas
- Monitoring
- Auditing
-
FAQs
-
Instances
- What RabbitMQ Version Does DMS for RabbitMQ Use?
- What SSL Version Does DMS for RabbitMQ Use?
- Why Can't I View the Subnet and Security Group Information During Instance Creation?
- What If One RabbitMQ VM Fails to Be Restarted When a Cluster RabbitMQ Instance Is Being Restarted?
- How Are Requests Evenly Distributed to Each VM of a Cluster RabbitMQ Instance?
- Do Queues Inside a Cluster RabbitMQ Instance Have Any Redundancy Backup?
- Does DMS for RabbitMQ Support Data Persistence? How Do I Perform Scheduled Data Backups?
- How Do I Obtain the Certificate After SSL Has Been Enabled?
- Can I Change the SSL Setting of a RabbitMQ Instance?
- Can RabbitMQ Instances Be Scaled Up?
- Does DMS for RabbitMQ Support MQTT?
- How Do I Clear Queue Data?
- Does DMS for RabbitMQ Support CPU and Memory Upgrades?
- How Do I Disable the RabbitMQ Management UI?
- Can I Change the AZ for an Instance?
-
Connections
- How Do I Configure a Security Group?
- Why Does a Client Fail to Connect to a RabbitMQ Instance?
- Does DMS for RabbitMQ Support Public Access?
- Does DMS for RabbitMQ Support Cross-Region Deployment?
- Does DMS for RabbitMQ Support Cross-VPC Access?
- Does DMS for RabbitMQ Support Cross-Subnet Access?
- What Should I Do If I Fail to Access a RabbitMQ Instance with SSL Encryption?
- Can I Access a RabbitMQ Instance Using DNAT?
- Why Can't I Open the Management Web UI?
- Can a Client Connect to Multiple Virtual Hosts of a RabbitMQ Instance?
- Why Does a RabbitMQ Cluster Have Only One Connection Address?
- Plug-ins
- Messages
- Monitoring & Alarm
-
Instances
- Change History
- API Reference (Kuala Lumpur Region)
-
User Guide (ME-Abu Dhabi Region)
- General Reference
Copied.
Accessing RabbitMQ on a Client (SSL Enabled)
This section takes the example of a demo of DMS for RabbitMQ to describe how to access a RabbitMQ instance with SSL enabled on a RabbitMQ client for message production and consumption. If SSL is enabled, data will be encrypted before transmission for enhanced security.
Prerequisites
- A RabbitMQ instance with SSL enabled has been created following the instructions in Buying a RabbitMQ Instance. The username and password entered in the instance creation have been obtained.
- Instance Address (Private Network) or Instance Address (Public Network) has been recorded.
- The network between the client server and the RabbitMQ instance has been established. For details about network requirements, see RabbitMQ Network Connection Requirements.
- JDK v1.8.111 or later has been installed on the client server, and the JAVA_HOME and PATH environment variables have been configured as follows:
Add the following lines to the .bash_profile file in the home directory as an authorized user. In this command, /opt/java/jdk1.8.0_151 is the JDK installation path. Change it to the path where you install JDK.
export JAVA_HOME=/opt/java/jdk1.8.0_151 export PATH=$JAVA_HOME/bin:$PATH
Run the source .bash_profile command for the modification to take effect.
- In the RabbitMQ instance: A virtual host, exchange, and queue have been created and an exchange-queue binding has been configured.
Accessing the Instance in CLI Mode
- Log in to the client server.
- Run the following command to download RabbitMQ-Tutorial-SSL.zip (code package of the sample project):
wget https://dms-demo.obs.cn-north-1.myhuaweicloud.com/RabbitMQ-Tutorial-SSL.zip
- Run the following command to decompress RabbitMQ-Tutorial-SSL.zip:
unzip RabbitMQ-Tutorial-SSL.zip
- Run the following command to navigate to the RabbitMQ-Tutorial-SSL directory, which contains the precompiled JAR file:
cd RabbitMQ-Tutorial-SSL
- Produce messages using the sample project.
java -cp .:rabbitmq-tutorial-sll.jar Send {host} {port} {user} {password}
Parameter description:
- {host}: connection address obtained in Prerequisites
- {port}: port of the RabbitMQ instance. Enter 5671.
- {user}: username obtained in Prerequisites
- {password}: password obtained in Prerequisites
Figure 1 Sample project for message creation - Consume messages using the sample project.
java -cp .:rabbitmq-tutorial-sll.jar Recv {host} {port} {user} {password}
Parameter description:
- {host}: connection address obtained in Prerequisites
- {port}: port of the RabbitMQ instance. Enter 5671.
- {user}: username obtained in Prerequisites
- {password}: password obtained in Prerequisites
Figure 2 Sample project for message retrievalTo stop retrieving messages, press Ctrl+C to exit.
Java Sample Code
- Accessing an instance and producing messages
- VHOST_NAME: name of the virtual host that contains the queue for messages to be sent to
- QUEUE_NAME: name of the queue for messages to be sent to
- Hello World!: the message to be sent in this sample
ConnectionFactory factory = new ConnectionFactory(); factory.setHost(host); factory.setPort(port); factory.setVirtualHost("VHOST_NAME"); factory.setUsername(user); factory.setPassword(password); factory.useSslProtocol(); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(QUEUE_NAME, false, false, false, null); String message = "Hello World!"; channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8")); System.out.println(" [x] Sent '" + message + "'"); channel.close(); connection.close();
- Accessing an instance and consuming messages
- VHOST_NAME: name of the virtual host that contains the queue to consume messages
- QUEUE_NAME: name of the queue to consume messages
ConnectionFactory factory = new ConnectionFactory(); factory.setHost(host); factory.setPort(port); factory.setVirtualHost("VHOST_NAME"); factory.setUsername(user); factory.setPassword(password); factory.useSslProtocol(); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(QUEUE_NAME, false, false, false, null); System.out.println(" [*] Waiting for messages. To exit press CTRL+C"); Consumer consumer = new DefaultConsumer(channel) { @Override public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException { String message = new String(body, "UTF-8"); System.out.println(" [x] Received '" + message + "'"); } }; channel.basicConsume(QUEUE_NAME, true, consumer);
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