1. A quick start to RocketMQ

RocketMQ is the MQ middleware of Alibaba in 2016, which is developed with Java language. Within Ali, RocketMQ has undertaken the message flow of high concurrency scenarios such as “Double 11” and can process the messages of trillion level.

1.1 Preparations

1.1.1 download RocketMQ

RocketMQ version: 4.4.0

Download address

1.1.2 Environment Requirements

  • On a system
  • JDK1.8(64位)
  • Source code installation requires Maven 3.2.x installed

1.1.3 Common Plug-in Installation Commands

Decompress the file yum install -y unzip zip Windows Upload the file yum -y install LRZSZ to the centos serverCopy the code

1.2 installation RocketMQ

1.2.1 Installation Procedure

This tutorial is installed as a binary package

1.2.1.1 Use rz to upload the downloaded compressed file to the specified centos directory

1.2.1.2. Decompress rocket4.4

Unzip - d/usr/software rocketmq - all - 4.4.0 - bin - the zipCopy the code

1.2.2 Introduction to Directories

  • Benchmark: Some code examples for RocketMQ
  • Bin: startup scripts, including shell scripts and CMD scripts
  • Conf: instance configuration files, including broker configuration files and logback configuration files
  • Lib: relies on JAR packages, including Netty, Commons-lang, and FastJSON

1.3 start RocketMQ

  1. Start the NameServer
# 1. Start NameServer nohup sh bin/ mqNamesrv & # 2 Check the startup log tail -f ~ / logs/rocketmqlogs/namesrv logCopy the code
  1. Start the Broker
Nohup sh bin/ mqBroker -n localhost:9876 & # 2. Check the startup log tail - f ~ / logs/rocketmqlogs/broker. The logCopy the code
  • Problem description:

    The default RocketMQ VM has a large memory. If the Broker fails to start due to insufficient memory, you need to edit the following two configuration files to change the JVM memory size

# Edit runbroker. Sh and runserver.sh to change the default JVM size vi runbrokerCopy the code
  • Reference Settings:

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

1.4 test RocketMQ

1.4.1 Sending a Message

Set environment variable export NAMESRV_ADDR=localhost:9876 # 2. Use the installation package Demo messaging sh bin/view sh org. Apache. Rocketmq. Example. Quickstart. ProducerCopy the code

1.4.2 Receiving messages

Set environment variable export NAMESRV_ADDR=localhost:9876 # 2. Receive messages sh bin/tools. Sh org. Apache. Rocketmq. Example. The quickstart. ConsumerCopy the code

1.5 close RocketMQ

NameServer sh bin/mqshutdown namesrv # 2. Close the Broker sh bin/mqshutdown BrokerCopy the code