This topic describes how to use the RocketMQ 4.x or 3.x SDK for Java to access an Alibaba Cloud ApsaraMQ for RocketMQ instance to send and receive messages.

Important
  • We recommend that you use the latest RocketMQ 5.x SDKs. These SDKs are fully compatible with the ApsaraMQ for RocketMQ 5.x brokers and provides more functions and enhanced features. For more information, see Release notes.
  • Alibaba Cloud only maintains RocketMQ 4.x, 3.x, and TCP client SDKs. We recommend that you use them only for existing business.

Version description

You can download the RocketMQ 4.x SDK for Java from the following URL: Apache RocketMQ SDK for Java. We recommend that you use the latest version.

Before you start

Perform the following operations in sequence:
  1. Import Maven dependencies.
  2. Create resources in the Alibaba Cloud ApsaraMQ for RocketMQ console.

For more information, see Preparations.

Use the SDK for Java to send and receive messages

Sample code