All Products
Search
Document Center

ApsaraMQ for RocketMQ:Send and receive messages with the RocketMQ 4.x/3.x SDK for Java

Last Updated:Mar 11, 2026

Use the RocketMQ 4.x or 3.x SDK for Java to connect to an ApsaraMQ for RocketMQ instance and send and receive messages.

Important

The RocketMQ 5.x SDKs are fully compatible with ApsaraMQ for RocketMQ 5.x brokers and provide more features. We recommend that you use the latest RocketMQ 5.x SDKs. Alibaba Cloud maintains the RocketMQ 4.x, 3.x, and TCP client SDKs for existing workloads only.

Download the SDK

Download the RocketMQ 4.x SDK for Java from Apache RocketMQ SDK for Java. Use the latest release.

Prerequisites

Before you begin, complete the following steps in order:

  1. Import Maven dependencies.

  2. Create resources in the ApsaraMQ for RocketMQ console.

For more information, see Preparations.

Send and receive messages

For producer and consumer examples that show how to connect to an ApsaraMQ for RocketMQ instance with the 4.x SDK, see Sample code.

What's next

  • Sample code -- Producer and consumer examples for the RocketMQ 4.x SDK.

  • Release notes -- Version history and updates for the RocketMQ 5.x SDKs.