Before using the Java SDK to send and subscribe to messages, follow the steps in this topic to prepare the environment.

Procedure

  1. Use either of the following methods to add the dependency of the Java SDK:
    • Use Maven:
      <dependency>
          <groupId>com.aliyun.openservices</groupId>
          <artifactId>ons-client</artifactId>
          <version>"XXX"</version>
          // Enter the latest Java SDK version.
      </dependency>                            
    • Download the dependency JAR package: For the download link of the latest version of Java SDK, see Release notes of Java SDK.
  2. Resource information such as the topic and group ID in the code must have been created in the Message Queue for Apache RocketMQ console first.

What to do next

Log configuration.

References

After preparing the environment, you can send and subscribe to messages as needed.