Alibaba Cloud RocketMQ—Take you through the experience of Cloud Message Queue RocketMQ

Alibaba Cloud Product Evaluation-RocketMQ

Friends who have not tried it can click to get resources for free , and enter practice with me! Take two minutes to complete the task and you will have the opportunity to receive a 10 yuan cat super card!
insert image description hereAt present, friends are invited to participate in the trial, and to learn about the evaluation activities, you can join the challenge!
Alibaba Cloud RocketMQ Official Event Entrance
insert image description here

Today I conducted an in-depth evaluation of another product of Ali (RocketMQ).

1. Hands-on operation

1. Pay or open RocketMQ for free

Cloud Message Queue RocketMQ Edition is a distributed message processing system based on Apache RocketMQ launched by Alibaba Cloud. It can meet the needs of Internet distributed applications such as asynchronous decoupling of microservices, streaming data processing, and event-driven processing, and provides core capabilities of high availability, high reliability, low latency, and high concurrency.
insert image description here

2. Enter the console to view:

insert image description here

3. The list of examples is as follows:

insert image description here

4. Create a Topic and fill in the corresponding configuration

Topic refers to the classification of messages in the message queue. Messages in the message queue will be classified according to Topic, and messages in different Topics will not be mixed together. Through Topic, precise search and filtering of messages can be realized, and the utilization rate and flexibility of messages can be improved. For example, you can create a Topic for processing user order information, and another Topic for processing user behavior statistics, so as to realize message classification and distribution.
insert image description here

5. One-click message sending and receiving experience

The one-click message sending and receiving experience will provide some convenient functions, such as automatic saving, one-click sending, one-click receiving, message filtering, etc. Using these functions, you can easily realize the interaction and delivery of messages and improve work efficiency. In addition, the one-click message sending and receiving experience can also provide some security functions, such as message encryption, identity verification, etc., to ensure the security of messages.

insert image description here

The details of the message are as follows:
insert image description here

6. Create a Group

Group refers to the grouping method of messages in the message queue. Messages in the message queue can be grouped according to Group, and messages in the same group will be sent to the queue together. Through Group, batch sending and batch receiving of messages can be realized, and the efficiency and stability of message transmission can be improved. For example, you can create a Group for processing user order information, and another Group for processing user behavior statistics, so as to realize batch sending and batch receiving of messages.
insert image description here
Message reissue tool
insert image description here

2. Experience scenario: one-click message sending and receiving experience

The official source code of one-click message sending and receiving experience is as follows:

package com.aliyun.openservices;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.rocketmq.client.apis.producer.SendReceipt;
import org.apache.rocketmq.client.apis.producer.Producer;
import org.apache.rocketmq.client.apis.ClientServiceProvider;
import org.apache.rocketmq.client.apis.ClientConfiguration;
import org.apache.rocketmq.client.apis.ClientConfigurationBuilder;
import org.apache.rocketmq.client.apis.ClientException;
import org.apache.rocketmq.client.apis.StaticSessionCredentialsProvider;
import org.apache.rocketmq.client.apis.message.MessageBuilder;

public class Demo {
    
    
    /**
     * 实例接入点,从控制台实例详情页的接入点页签中获取。
     * 如果是在阿里云内网 VPC 访问,建议填写 VPC 接入点。
     * 如果是在本地公网访问,或者是线下 IDC 环境访问,可以使用公网接入点。使用公网接入点访问,必须开启实例的公网访问功能。
     */
    public static final String ENDPOINT = "rmq-cn-uax3azb880h-vpc.cn-hangzhou.rmq.aliyuncs.com:8080";
    public static final String TOPIC_NAME = "xiaoz";
    public static final String TAG = "";
    public static final String KEY = "";
    public static final String BODY = "good";

    public static void main(String[] args) throws ClientException, IOException {
    
    
        ClientServiceProvider provider = ClientServiceProvider.loadService();
        ClientConfigurationBuilder configBuilder = ClientConfiguration.newBuilder().setEndpoints(ENDPOINT);

        /**
         * 如果是使用公网接入点访问,configuration 还需要设置实例的用户名和密码。用户名和密码在控制台实例详情页获取。
         * 如果是在阿里云内网 VPC 中访问,无需填写该配置,服务端会根据内网 VPC 信息智能获取。
         */
        // configBuilder.setCredentialProvider(
        //  new StaticSessionCredentialsProvider("Instance UserName", "Instance Password")
        // );
        ClientConfiguration configuration = configBuilder.build();

        /**
         * 初始化 Producer 时直接配置需要使用的 Topic 列表,实现提前检查错误配置、拦截非法配置启动。
         * 针对非事务消息 Topic,也可以不配置,服务端会动态检查消息的 Topic 是否合法。
         * 注意!!!事务消息 Topic 必须提前配置,以免事务消息回查接口失败,具体原理请参见事务消息。
         */
        Producer producer = provider.newProducerBuilder()
                .setClientConfiguration(configuration)
                .setTopics(TOPIC_NAME)
                .build();

        MessageBuilder builder = provider.newMessageBuilder()
                // 为当前消息设置 Topic。
                .setTopic(TOPIC_NAME)
                // 消息体。
                .setBody(BODY.getBytes(StandardCharsets.UTF_8));

        if (!KEY.isEmpty()) {
    
    
            // 设置消息索引键,可根据关键字精确查找某条消息。
            builder.setKeys(KEY);
        }

        if (!TAG.isEmpty()) {
    
    
            // 设置消息 Tag,用于消费端根据指定 Tag 过滤消息。
            builder.setTag(TAG);
        }

        // 配置消息的自定义属性
        // builder.addProperty("key", "value");

        try {
    
    
            // 发送消息,需要关注发送结果,并捕获失败等异常。
            final SendReceipt sendReceipt = producer.send(builder.build());
            System.out.println("Send mq message success! Topic is:" + TOPIC_NAME + " msgId is: "
                    + sendReceipt.getMessageId().toString());
        } catch (Throwable t) {
    
    
            System.out.println("Send mq message failed! Topic is:" + TOPIC_NAME);
            t.printStackTrace();
        }
        
        // 如果不需要再使用,可关闭该进程。
        producer.close();
    }
}

My example:
insert image description here
message track:
insert image description here
message details are as follows:
insert image description here

2.1 RocketMQ actual use experience

Novice experience:

1) Product use process: through simple operations, you can quickly send and receive messages, which is convenient and fast, and easy to use.
2) Learning suggestions: It is recommended that users learn more about the basics of message queues in order to better use the one-click message sending and receiving experience.

Advanced experience:

1) Source code experience: Through the understanding of the source code, you can have a deeper understanding of the realization principle of the one-click message sending and receiving experience, and improve your understanding of message queues.
2) Scenario application: This function tends to be used in scenarios that require fast interaction and message delivery, such as online education, e-commerce platforms, etc. This can improve work efficiency and improve user experience.
3) Advantages: easy to use, fast and efficient, convenient and practical. Aspects for improvement: It may be necessary to further optimize functions such as message filtering and provide more customization options to meet the needs of different users.

2.2 Usage Scenario Tendency

I tend to use this function of RocketMQ in scenarios that require fast interaction and message delivery, such as online education, e-commerce platforms, etc. This can improve work efficiency and improve user experience. In addition, the use of RocketMQ can improve the stability and reliability of message transmission, reduce the risk of message loss and delay, thereby improving the availability and scalability of the system, and bringing more benefits and value to the company.

2.3 Feelings about the experience: advantages and suggestions for improvement

The main advantages of this scenario are as follows:
● Ease of use: Quickly send and receive messages through simple operations, which is convenient and fast, and easy to use.
● Fast and efficient: batch sending and receiving of messages can be realized, improving the efficiency and stability of message transmission.
● Convenient and practical: It can provide some convenient functions, such as automatic saving, one-key sending, one-key receiving, message filtering, etc., to improve work efficiency.
The main aspects to be improved are:
● Customization: It may be necessary to further optimize functions such as message filtering and provide more customization options to meet the needs of different users.
● Security: Consider adding some security functions, such as message encryption and authentication, to ensure message security.

Friends who are interested in RocketMQ can try it in the official link:
Alibaba Cloud RocketMQ official entrance

Guess you like

Origin blog.csdn.net/weixin_52908342/article/details/131773048