2. 10th day learning check-in ---- RocketMQ for beginners (1)
2. 10th day learning check-in ---- RocketMQ for beginners (1)
2. Study clock in on the 10th
Table of contents:
- 2. Study clock in on the 10th
- 1. RocketMQ Overview
-
- development path
- RocketMQ concept terminology
- 2. RocketMQ installation and configuration
-
- Environment setup and testing
- RocketMQ management commands
For some explanations of MQ (Message queue) message queue , you can read my original article Learning RabbitMQ for Beginners
Comparison of major MQ products
1. RocketMQ Overview
development path
RocketMQ concept terminology
- Producers and consumers
Producers are responsible for producing messages. Generally, the business system is responsible for producing messages. The consumer is the backend system, which is responsible for consuming messages.
- Message Model (Message Model)
The message model mainly includes the queue model and the publish-subscribe model. RabbitMQ uses the queue model, as shown in the figure below.
RocketMQ uses the publish-subscribe model. The model is shown in the figure:
- Topic
Represents a collection of messages of a type. Each topic contains several messages. Each message can only belong to one topic. It is the basic unit of RocketMQ for message subscription.
- Broker Server
The message relay role is responsible for storing and forwarding messages.
- Name Server
The name service management proxy server broker is equivalent to a management organization.
-
Producer Group
is a collection of Producers of the same type. This type of Producers sends the same type of messages and has consistent sending logic. -
Consumer Group
A collection of consumers of the same type. This type of Consumer usually consumes the same type of messages and has consistent consumption logic.
- Pull Consumer
A type of Consumer consumption. The application usually actively calls the Consumer's message pull method to pull messages from the Broker server. The initiative is controlled by the application. Once the batch of messages is obtained, the application starts the consumption process.
- Push Consumer
A type of consumer consumption. In this mode, the Broker will actively push the data to the consumer after receiving it. This consumption mode generally has high real-time performance.
-
Normal Ordered Message
! [Insert picture description here](https://img-blog.csdnimg.cn/direct/9178444faae640769fb8dca7c5633f2b.png
In normal ordered consumption mode, consumers pass through the same message queue (Topic partition , called Message Queue) The messages received are in order, but the messages received by different message queues may be out of order. -
Strictly Ordered Message
In the strictly ordered message mode, all messages received by consumers are in order.
2. RocketMQ installation and configuration
Environment setup and testing
Download address: [https://rocketmq.apache.org/zh/release-notes/](https://rocketmq.apache.org/zh/release-notes/)
Select the second binary installation
- First upload the file to the virtual machine using the rz command
- Unzip the file unzip rocketmq-all-5.1.4-bin-release.zip (your own version)
- Rename the folder name to facilitate modification of mv rocketmq-all-5.1.4-bin-release rocketmq-5.1.4
- Move the folder to the /usr/local directory mv rocketmq-5.1.4 /usr/local
- Modify the environment variable
vim /etc/profile
export JAVA_HOME=/usr/local/jdk-11.0.11/
export PATH=$PATH:$JAVA_HOME/bin
export ROCKETMQ_HOME=/usr/local/rocketmq-5.1.4(自己的版本)
export PATH=$PATH:$ROCKETMQ_HOME/bin
- Start NameServer nohup sh mqnamesrv &
- Start broker nohup sh mqbroker -n localhost:9876
RocketMQ management commands
mqadmin help command name
- Start namesrv and broker
./mqnamesrv #Start nameserver
./mqbroker -n localhost:9876 -c /opt/alibaba-rocketmq/conf/broker.conf #Start broker
- #Start broker
tail -f ~/logs/rocketmqlogs/namesrv.log
#View the log
tail -f ~/logs/rocketmqlogs/broker.log
#View the log
- Add new topic
mqadmin updateTopic -n localhost:9876 -c DefaultCluster -t topicWarning
- Check the status of a topic
mqadmin topicStatus -n localhost:9876 -t topicWarning
- View all consumer groups
mqadmin consumerProgress -n localhost:9876
- View all topics
mqadmin topicList -n localhost:9876
- Delete topic
mqadmin deleteTopic -n localhost:9876 -c DefaultCluster -t topicWarning
- Close namesrv and broker services
mqshutdown namesrv
mqshutdown broker
If my content is helpful to you, pleaseLike, comment, favorite. creationIt’s not easy, everyone’s support is what keeps me going!