Quick Guide to Installing, Configuring, and Using Apache RocketMQ 4.2

This tutorial provides a step‑by‑step walkthrough for setting up Apache RocketMQ 4.2 on a 64‑bit Linux system, covering environment prerequisites, downloading source, building binaries, starting NameServer and Broker, sending and receiving messages, and shutting down the services.

Architect's Tech Stack
Architect's Tech Stack
Architect's Tech Stack
Quick Guide to Installing, Configuring, and Using Apache RocketMQ 4.2

Environment Requirements

Use a 64‑bit Linux/Unix OS (e.g., CentOS 7.3) with JDK 1.8+, Maven 3.2.x installed. Install JDK and Maven as needed.

Download and Build

Download the source package:

wget https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.2.0/rocketmq-all-4.2.0-source-release.zip

Unzip and build:

unzip rocketmq-all-4.2.0-source-release.zip
cd rocketmq-all-4.2.0
mvn -Prelease -DskipTests clean install

After the build finishes, the distribution can be found under distribution/target/apache-rocketmq. The build logs show a series of SUCCESS messages for each module.

Start NameServer

Edit bin/runserver.sh to set JVM options, e.g.:

JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

Start the NameServer in background: nohup sh bin/mqnamesrv > /dev/null 2>&1 & Verify the startup log contains "NameServer boot success".

Start Broker

Similarly adjust bin/runbroker.sh JVM options: JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m" Start the broker:

nohup sh bin/mqbroker -n localhost:9876 > /dev/null 2>&1 &

Check the broker log for "broker [...] boot success".

Verify Processes

jps
netstat -ntlp

Ensure NamesrvStartup and BrokerStartup are listening on ports 9876 and 10911 respectively.

Send and Receive Messages

Set the NameServer address: export NAMESRV_ADDR=localhost:9876 Run the provided quick‑start producer and consumer examples:

sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer

The producer prints a SendResult with sendStatus=SEND_OK, and the consumer logs received messages.

Stop Services

Shutdown the broker: sh bin/mqshutdown broker Shutdown the NameServer: sh bin/mqshutdown namesrv Both commands send a shutdown request and confirm termination.

Contact

Author: Peng Lei – http://www.ymq.io/2018/01/29/MongoDB-2 – Email: [email protected] – WeChat: "搜云库" (public account for development knowledge sharing).

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavamavenLinuxMessage QueueRocketMQInstallationBroker
Architect's Tech Stack
Written by

Architect's Tech Stack

Java backend, microservices, distributed systems, containerized programming, and more.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.