All Products
Search
Document Center

ApsaraMQ for RocketMQ:Set up the Java SDK environment

Last Updated:Mar 11, 2026

Set up the Apache RocketMQ SDK for Java to send and receive messages through ApsaraMQ for RocketMQ 5.x.

Step 1: Install the SDK

Import dependencies by using Maven or download the JAR package. For the latest SDK version, see Recommended versions.

Step 2: Create cloud resources

Create the following resources in the ApsaraMQ for RocketMQ console before you run sample code:

ResourceDescription
Instance endpointThe URL that your client uses to connect to ApsaraMQ for RocketMQ
TopicThe destination that producers send messages to
Consumer groupA grouping of consumers that subscribe to topics

For step-by-step instructions, see Step 2: Create resources.

Step 3: Run the demo project

  1. Clone the demo project from GitHub.

  2. Update the connection parameters in the sample code with the resources from Step 2.

  3. Build and run the project.

Note

If your project uses the rocketmq-client SDK instead of rocketmq-client-java, you do not need to download the demo project. See Sample code for integration examples.