Ali open source Apache RocketMQ is a high-performance, high-throughput distributed messaging middleware.
Official website: http://rocketmq.apache.org/
Feature
- Consumer end support and message filtering Broker
- Supports publish-subscribe model, and point to point,
- Push pull and push pull supports two message mode
- Single queue millions of messages, one hundred million messages pile up
- Support single master node, multi-master node, multi-master multi slave node
- Any point are highly available, the level of expansion, Producer, Consumer, queues can be distributed
- Message failure retry mechanism to support a certain level of timing messages
- The new version uses the underlying Netty
- 4.3.x support distributed transactions
- For financial services, high availability, tracking and auditing capabilities.
concept
- Producer: news producer
- Producer Group: Group message producers, sending the same message to a group message production
- Consumer: Consumers
- Consumer Group: Consumer multiple instances of the same message
- Tag: label subtopics (secondary classification) further refinement of topic for the message to distinguish different services at the same theme
- Topic: themes, such as order type of message, queue management unit is a physical message, and the topic is the logical management unit. The next topic can have multiple Queue, automatically creates a default 4, to manually create eight
- Message: message, each message must specify a topic
- Broker: MQ program to receive production information available to consumer spending program
- Name Server: to produce and provide consumers with routing information, providing lightweight service discovery, routing, metadata information, you can deploy multiple, independent of each other (lighter than the zookeeper)
- Offset: Offset, it can be understood as message schedule
- commit log: write messages are stored in the Commit log file inside
Learning Resources: http://jm.taobao.org/2017/01/12/rocketmq-quick-start-in-10-minutes/
Installation Prerequisites (recommended) 64bit OS, Linux / Unix / Mac 64bit (Windows is not compatible), JDK 1.8+;
Quick Start http://rocketmq.apache.org/docs/quick-start/
Here virtual machine as an example to Centos 7.2
Installation JDK1.8
The first step: Get JDK1.8 installation package
Address: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Step Two: Extracting installation packages
Create a new folder, to place the installation package (course possible to use any folder) into the directory / usr / local / software
Decompression: tar -zxvf jdk-8u201-linux -x64.tar.gz
rename: mv jdk1.8.0_201 jdk8
Note: The generated unzip the folder is: jdk1.8.0_201, I'm here to rename purpose is to look at their own convenience, in fact, do not rename it does not matter
The third step: configuration environment variable
vim /etc/profile
Add the following configuration
export JAVA_HOME=/usr/local/software/jdk8 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME PATH CLASSPATH
Use source / etc / profile so that configuration to take effect immediately
Note: JAVA_HOME to their actual circumstances prevail. I have here is: / usr / local / software / jdk8
Installing Maven
The first step: Get the installation package
Address: http://maven.apache.org/download.cgi
Step Two: Extracting installation packages
Decompression: tar -zxvf apache-maven-3.6.0 -bin.tar.gz
rename: mv apache-maven-3.6.0 maven
The third step: configuration environment variable
vim /etc/profile
Add the following configuration
export PATH=/usr/local/software/maven/bin:$PATH
Use source / etc / profile so that configuration to take effect immediately
Installation RocketMQ4.X
The first step: Get the installation package
Address: https://mvnrepository.com/search?q=mybatis
The second step: unpack compile and install the package
unzip rocketmq-all-4.4.0-source-release.zip cd rocketmq-all-4.4.0/ mvn -Prelease-all -DskipTests clean install -U
Note: I had here is to rename the folder, the original folder name is: rocketmq-all-4.4.0
The third step: start
Start nameServer
cd /usr/local/software/rocketmq-all-4.4.0/distribution/target/apache-rocketmq nohup sh bin/mqnamesrv &
View log tail -f nohup.out (end:. The Name Server boot success serializeType = JSON represents a successful start)
Start broker (-n nameserver specified address, nameserver service port is 9876, broker default port 10911)
cd /usr/local/software/rocketmq-all-4.4.0/distribution/target/apache-rocketmq nohup sh bin/mqbroker -n localhost:9876 &
Close the command nameserver broker execution
cd /usr/local/software/rocketmq-all-4.4.0/distribution/target/apache-rocketmq sh bin/mqshutdown broker sh bin/mqshutdown namesrv
View the process using jps
Step Four: Test
CD / usr / local / Software / rocketmq-all- 4.4 . 0 / Distribution / target / Apache - An rocketmq # Name Set service address Export NAMESRV_ADDR = localhost: 9876 # delivery message SH bin / tools.sh org.apache.rocketmq.example .quickstart.Producer SendResult [SendStatus = SENDOK, msgId = ... # message consumer SH bin / tools.sh org.apache.rocketmq.example.quickstart.Consumer ConsumeMessageThread_ % D the Receive the messages New: [... MessageExt
common problem
-
NameServer memory is not enough how to deal with
-
Find runserver.sh modify JAVA_OPT
报错问题如下 [root@iZwz94sw188z3yfl7lpmmsZ apache-rocketmq]# sh bin/mqnamesrv Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ec800000, 2147483648, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 2147483648 bytes for committing reserved memory. # An error report file with more information is saved as: # /Usr/local/software/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/hs_err_pid8993.log solve the following edit bin / runserver.sh: JAVA_OPT = "{$} JAVA_OPT -server -Xms256m -Xmx256m - Xmn256m -XX: MetaspaceSize = 128m -XX: MaxMetaspaceSize = 320m "
-
-
Broker insufficient memory
-
Find runbroker.sh modify JAVA_OPT
-
JAVA_OPT="${JAVA_OPT} -server -Xms528m -Xmx528m -Xmn256m"
-
Note: runserver.sh and runbroker.sh these two files in the directory where /usr/local/software/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/bin