This topic describes how to use Message Queue for Apache RocketMQ to send and subscribe to messages in the Spring framework.

Background information

Message Queue for Apache RocketMQ allows you to integrate the following types of producers and consumers with Spring:
  • Producers and consumers of standard messages
  • Producers and consumers of transactional messages
  • Producers and consumers of ordered messages

Parameters

The following table describes the parameters that are required for the integration with Spring.

Parameter Description
GROUP_ID The ID of the group that you create in the Message Queue for Apache RocketMQ console. You can use the ID to group consumers or producers. For more information, see Terms.
AccessKey The AccessKey ID that you create for identity authentication. You can obtain the AccessKey ID of the Alibaba Cloud account in the Alibaba Cloud Management Console.
SecretKey The AccessKey secret that you create for identity authentication. You can obtain the AccessKey secret of the Alibaba Cloud account in the Alibaba Cloud Management Console.
NAMESRV_ADDR The TCP endpoint of your instance. To obtain the TCP endpoint, log on to the Message Queue for Apache RocketMQ console, find the instance on the Instances page and then click Details in the Actions column to go to the Instance Details page. The TCP endpoint is displayed in the TCP Endpoint section on the Endpoints tab.
expression The filter expression that is used to filter messages by tag. A filter expression of Tag A||Tag B indicates that consumers subscribe to messages with Tag A, Tag B, or both in a topic. For more information, see Subscribe to messages.

For more information about the parameters used in the integration with Spring, see Methods and parameters.

Download demos

The following demos are provided for you to implement the integration with Spring: