All Products
Search
Document Center

ApsaraMQ for RocketMQ:Preparations

Last Updated:Mar 11, 2026

Set up the Java SDK and create the required cloud resources before sending and receiving messages with ApsaraMQ for RocketMQ.

Important

ApsaraMQ for RocketMQ offers multiple SDK generations. The latest RocketMQ 5.x SDKs are fully compatible with ApsaraMQ for RocketMQ 5.x brokers and provides more functions and enhanced features. For details, see Release notes.

Alibaba Cloud only maintains the RocketMQ 4.x, 3.x, and TCP client SDKs for existing business. For new projects, use the 5.x SDKs.

Prerequisites

Before you begin, make sure that you have:

  • Build tool: Maven installed, or the ability to download JAR packages manually

Add dependencies

Add the Message Queue for Apache RocketMQ SDK for Java to your project using one of the following methods.

Maven (recommended)

Add the following dependencies to your pom.xml:

<dependency>
    <groupId>org.apache.rocketmq</groupId>
    <artifactId>rocketmq-client</artifactId>
    <version>4.9.4</version>
    <!--We recommend that you update to the latest version-->
</dependency>
<dependency>
    <groupId>org.apache.rocketmq</groupId>
    <artifactId>rocketmq-acl</artifactId>
    <version>4.9.4</version>
    <!--We recommend that you update to the latest version-->
</dependency>

Manual JAR download

Download the dependency JAR packages from the Apache RocketMQ official website.

Create resources

Before writing producer or consumer code, create the following resources in the ApsaraMQ for RocketMQ console: instances, topics, and group IDs.

For step-by-step instructions, see Create resources.

Send and receive your first message

After creating the required resources, see Sample code for complete producer and consumer examples.