Introduce a,

Apache RocketMQ is a distributed, queued model of messaging middleware with low latency, high performance and reliability, trillion-scale capacity, and flexible scalability. The core component consists of four parts: Name Servers, Brokers, Producer and Consumer. Each of them can scale horizontally without a single failed node.

  


NameServer: is a nearly stateless node that can be clustered and no information is synchronized between nodes

Broker: The deployment is relatively complex. Brokers are divided into Master and Slave brokers. A Master can correspond to multiple Slavers, but a Slaver can only correspond to one Master. A different BrokerId is defined, with a BrokerId 0 for Master and a non-0 for Slaver. Multiple Master can be deployed. Each Broker establishes long connections to all nodes in the NameServer cluster and periodically registers Topic information to all Nameservers

Producer: Establishes a long connection with a node (randomly selected) in the NameServer cluster, obtains Topic routing information from NameServer regularly, establishes a long connection with the Master that provides Topic services, and sends heartbeat messages to the Master periodically. Produce is stateless and can be clustered

Consumer: Establishes a long-term connection with a node (randomly selected) in the NameServer cluster, obtains Topic routing information from NameServer periodically, establishes a long-term connection with the Master and Slaver that provide Topic services, and periodically sends heartbeat messages to the Master and Slaver. Consumers can subscribe to messages from either Master or Slave, depending on the Broker configuration

Ii. MQ installation and deployment

Download 2.1.

Download the latest version and unpack it

http://rocketmq.apache.org/release_notes

  


2.2. Modify the configuration

** Modify conf/broker.conf** add the following configuration

  


BrokerIP1: Configure the IP address of the broker Server so that the Name Server can connect

Change runserver.sh and runbroker.sh (optional)

Because the rocketMQ default startup parameter is very memory intensive, the JAVA_OPT parameter must be modified if the environment does not have this amount of memory

runserver.sh

  


JAVA_OPT=${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m

runbroker.sh

  


JAVA_OPT=${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m

2.3. Run Name Server

nohup sh bin/mqnamesrv

Check run log: tail -f ~ / logs/rocketmqlogs/namesrv log

2.4. Run the Broker

nohup sh bin/mqbroker -n localhost:9876 -c conf/broker.conf

Specify the configuration file using the -c parameter

Check run log: tail – f ~ / logs/rocketmqlogs/broker. The log

2.5. Way to stop service

To stop the RocketMQ service, you are advised to run the kill command instead of the kill command in the production environment

sh bin/mqshutdown broker

sh bin/mqshutdown namesrv

Install a visual management interface

download

https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console

compile

mvn clean package -Dmaven.test.skip=true

run

nohup java -jar \

– Drocketmq. Config. NamesrvAddr = 192.168.28.130: \ 9876

-Drocketmq.config.isVIPChannel=false \

Rocketmq – the console – ng – 1.0.0. Jar

access

http://192.168.28.130:8080/

  


Four, common exception processing

4.1. MQClientException: No route info of this topic, TopicTest1

4.1.1. Exception Description

When the Producer of the client is running and ready to send messages, an exception is thrown as “No route info of this topic”. The possible causes are as follows:

The Broker disallows automatic creation of topics, and users do not create topics manually

The Broker is not properly connected to the Name Server

Producer is not properly connected to the Name Server

4.1.2. Solution

Troubleshooting 1: The Broker forbids automatic Topic creation and the user does not manually create a Topic

To view the broker configuration parameters, run sh bin/ mqbroker-m in the RocketMQ directory

As shown below, autoCreateTopicEnable=true proves that there is no problem

  


Troubleshoot 2: The Broker is not properly connected to the Name Server

By looking at the broker log tail – f ~ / logs/rocketmqlogs/broker. The log to see if there is any error information

Check 3: Producer is not correctly connected to the Name Server

Check whether the program connects to the Name Server at the correct address

If the security group is configured on a cloud server, check whether port 9876 is developed

See if the firewall is on, and if so, set up a firewall to open port 9876

4.2. RemotingTooMuchRequestException: sendDefaultImpl call a timeout

4.2.1. Exception Description

The following exception is thrown when the Producer of the client is up and ready to send messages

This is usually because the Name Server cannot connect to the Broker

  


4.2.2. Solution

Check the RocketMQ-Console cluster TAB for the correct broker address

  


Refer to the steps in installation and deployment to configure the broker address:

Modify the broker.conf configuration to add the brokerIP1 parameter

Start the broker with the -c parameter to specify the configuration file

4.3. Unable to consume/view messages from the dead-letter queue topic

  


4.3.1. Exception Description

The default perm value of a dead letter queue is 2

4.3.2. Solution

Change the queue’s PERM to 6 on the console

** TOPIC click TOPIC configuration **

  


Modify the perm