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.

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

Package the application. mvn clean package -Dmaven.test.skip=true Run the service. java -jar target/rocketmq-console-ng-2.0.0.jar Access the service.

Testing

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

<dependency>
  <groupId>org.apache.rocketmq</groupId>
  <artifactId>rocketmq-spring-boot-starter</artifactId>
  <version>2.2.0</version>
</dependency>

Configure the application:

rocketmq:
  nameServer: localhost:9876
  producer:
    group: demo-mq

Implement a message listener:

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

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

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:

mqadmin updatetopic -n localhost:9876 -c DefaultCluster -t test-topic

Automatic creation by enabling autoCreateTopicEnable=true in the broker configuration:

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

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

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.

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

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.