Backend Development 6 min read

How to Install, Configure, and Test RocketMQ Console 2.0 with Spring Boot

This guide walks you through setting up RocketMQ Console 2.0 on a RocketMQ 4.8.0 cluster, configuring its properties, building and running the service, and testing message sending and receiving using a Spring Boot application, including topic creation tips.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
How to Install, Configure, and Test RocketMQ Console 2.0 with Spring Boot

Introduction

rocketmq-console is an extension plugin for the RocketMQ project that provides a graphical management console for viewing broker cluster status, managing topics, displaying producer and consumer states, and querying messages. It must be installed and run separately after installing RocketMQ.

Download and Installation

Download the console from the provided URL.

Modify the related configuration.

Edit

src/main/resources/application.properties

to set the server address, port, context path, and service address. This version uses Spring Boot 2.2.2.

<code>server.address=0.0.0.0
# modify port
server.port=8088
# set context path
server.servlet.contextPath=/rocketmq

### SSL setting
#server.ssl.key-store=classpath:rmqcngkeystore.jks
#server.ssl.key-store-password=rocketmq
#server.ssl.keyStoreType=PKCS12
#server.ssl.keyAlias=rmqcngkey

#spring.application.index=true
spring.application.name=rocketmq-console
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
logging.level.root=INFO
logging.config=classpath:logback.xml
# NameServer address
rocketmq.config.namesrvAddr=localhost:9876
# VIP channel setting (depends on version)
rocketmq.config.isVIPChannel=
# Data path
rocketmq.config.dataPath=f:/rocketmq/datas
rocketmq.config.enableDashBoardCollect=true
rocketmq.config.msgTrackTopicName=
rocketmq.config.ticketKey=ticket
# Create users.properties if login is required
rocketmq.config.loginRequired=false</code>

Package the application.

<code>mvn clean package -Dmaven.test.skip=true</code>

Run the service.

<code>java -jar target/rocketmq-console-ng-2.0.0.jar</code>

Access the service.

Testing

Create a new Spring Boot project and add the following dependency:

<code>&lt;dependency&gt;
  &lt;groupId&gt;org.apache.rocketmq&lt;/groupId&gt;
  &lt;artifactId&gt;rocketmq-spring-boot-starter&lt;/artifactId&gt;
  &lt;version&gt;2.2.0&lt;/version&gt;
&lt;/dependency&gt;</code>

Configure the application:

<code>rocketmq:
  nameServer: localhost:9876
  producer:
    group: demo-mq</code>

Implement a message listener:

<code>@RocketMQMessageListener(topic = "test-topic", consumerGroup = "consumer01-group", selectorExpression = "tag1 || tag2")
@Component
public class ConsumerListener implements RocketMQListener&lt;String&gt; {

  @Override
  public void onMessage(String message) {
    System.out.println("Received message: " + message);
  }
}</code>

The

selectorExpression

specifies which tags the consumer can receive (tag1, tag2 in this example). Use the console to send messages.

Note: If you create a topic via the console and then send messages, you may encounter errors or no messages received because the console version may be too low for the RocketMQ version. You can create topics in two ways:

Command line:

<code>mqadmin updatetopic -n localhost:9876 -c DefaultCluster -t test-topic</code>

Automatic creation by enabling

autoCreateTopicEnable=true

in the broker configuration:

<code>mqbroker -n localhost:9876 autoCreateTopicEnable=true -c ../conf/broker.conf</code>

All set! Please give a follow if you found this helpful.

backendrocketmqMessagingTutorialconsolespring-boot
Spring Full-Stack Practical Cases
Written by

Spring Full-Stack Practical Cases

Full-stack Java development with Vue 2/3 front-end suite; hands-on examples and source code analysis for Spring, Spring Boot 2/3, and Spring Cloud.

0 followers
Reader feedback

How this landed with the community

login 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.