All Products
Search
Document Center

ApsaraMQ for RocketMQ:Preparations

Last Updated:Oct 12, 2023

This topic describes how to prepare the environment before you use the Message Queue for Apache RocketMQ SDK for Java 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.

Procedure

  1. Use one of the following methods to add a dependency:
    • Import a dependency by using Maven:
      <dependency>
          <groupId>org.apache.rocketmq</groupId>
          <artifactId>rocketmq-client</artifactId>
          <version>4.9.4</version>
          <!--We recommend that you update to the latest version-->
      </dependency>
      <dependency>
          <groupId>org.apache.rocketmq</groupId>
          <artifactId>rocketmq-acl</artifactId>
          <version>4.9.4</version>
          <!--We recommend that you update to the latest version-->
      </dependency>                           
    • Download a dependency JAR package.

      To download a dependency JAR package, visit the Apache RocketMQ official website.

  2. You must create resources that are referred to in the code of the Message Queue for Apache RocketMQ SDK for Java in the Alibaba Cloud ApsaraMQ for RocketMQ console. The resources include Alibaba Cloud ApsaraMQ for RocketMQ instances, topics, and group IDs.
    For more information, see Create resources.

What to do next

Sample code