Before you send and receive messages with the TCP client SDK for Java, add the SDK dependency to your project and create the required cloud resources.
We recommend that you use the latest RocketMQ 5.x SDKs. These SDKs are fully compatible with ApsaraMQ for RocketMQ 5.x brokers and provide more functions and enhanced features. For more information, see Java SDK version guide.
Alibaba Cloud only maintains RocketMQ 3.x, 4.x, and TCP client SDKs. We recommend that you use them only for existing business.
Prerequisites
Before you begin, make sure that you have:
A build tool such as Maven, or access to download JAR files manually
An Alibaba Cloud account with ApsaraMQ for RocketMQ activated
Step 1: Add the SDK dependency
Add the ons-client dependency to your project by using one of the following methods.
Option A: Maven (recommended)
Add the following dependency to your pom.xml file:
<dependency>
<groupId>com.aliyun.openservices</groupId>
<artifactId>ons-client</artifactId>
<!--Replace with the latest version number.-->
<version>1.8.8.1.Final</version>
</dependency>To find the latest version number, see Release notes.
Option B: Manual JAR download
Download the SDK JAR package from the Release notes page and add it to your project classpath.
Step 2: Create resources in the console
Create the topics and groups that your application requires in the ApsaraMQ for RocketMQ console. For instructions, see Step 2: Create resources.