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:
| Resource | Description |
|---|---|
| Instance endpoint | The URL that your client uses to connect to ApsaraMQ for RocketMQ |
| Topic | The destination that producers send messages to |
| Consumer group | A grouping of consumers that subscribe to topics |
For step-by-step instructions, see Step 2: Create resources.
Step 3: Run the demo project
Clone the demo project from GitHub.
Update the connection parameters in the sample code with the resources from Step 2.
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.