All Products
Search
Document Center

Simple Message Queue (formerly MNS):Overview

Last Updated:Sep 02, 2024

This topic describes the version source and sample code of Simple Message Queue (formerly MNS) SDK for Java.

Version source

You need to select a version based on your business requirements before you download SMQ SDK for Java. SMQ allows you to download SDK dependencies from Maven Repository and provides source sample code at GitHub.

Source

Description

Maven Repository

Maven Repository provides the source code packages of SMQ that you can download. You can obtain a Maven project from Maven Repository and add the required version of SMQ SDK for Java to the Maven project.

For more information, see Aliyun SMQ SDK for Java.

GitHub

GitHub provides the source sample code of SMQ SDK for Java and records tag information about the released versions of SMQ SDK. You can view the source code and sample code that you can use in various scenarios at GitHub. For more information, see Aliyun SMQ Java SDK Release.

Note
  • In this example, SMQ SDK for Java 1.1.10 is used. For more information, see Versions.

  • We recommend that you use the latest version of SMQ SDK for Java for debugging to prevent errors.

Sample code

SMQ SDK for Java provides a variety of sample code for your reference or use. The following table describes the sample code files provided by SMQ SDK for Java.

Scenario

Resource type

Content

References

Demo download

Basic usage

Request

Configure an access credential by using a Resource Access Management (RAM) role

Configure endpoints and access credentials

RamRoleCredentialsDemo.java

Queue

Message management

Send messages

Use sample code to send a message to a queue

SendMessageDemo.java

Receive and consume messages

Use sample code to receive messages

ReceiveMessageDemo.java

Topic

Message management

Send messages

Use sample code to send a message to a topic

PublishMessageDemo.java

Subscribe to topics to receive messages on downstream clients

Use sample code to subscribe to a topic

ConsumerQueueForTopicDemo.java

Subscription example

Use sample code to subscribe to a topic and receive messages by using an HTTPS subscription

Use sample code to create an HTTP subscription

HttpEndpointSubscription.java

Advanced scenario

Oversized message

Send and receive oversized messages

Transfer oversized messages

LargeMessageDemo.java

Concurrency

Perform a concurrency test

Perform a concurrency test

JavaSDKPerfTest.java