SDK reference overview

Updated at:

ApsaraMQ for RocketMQ provides SDKs for the TCP and HTTP protocols across multiple programming languages. This topic describes the differences between the two types of SDKs and how to use them.

Choose an SDK version

ApsaraMQ for RocketMQ SDK versions and their supported features are described in the following table:

In the following table, ✅ indicates that a feature is supported and ❌ indicates that a feature is not supported.

Item

RocketMQ 5.x gRPC SDK

RocketMQ 5.x Remoting SDK

RocketMQ 4.x/3.x SDK

RocketMQ ONS TCP 1.x SDK

RocketMQ ONS TCP 2.x SDK

RocketMQ ONS HTTP SDK

Protocol

gRPC protocol v2

Remoting protocol

Remoting protocol

Remoting protocol

gRPC protocol v1

HTTP protocol

Compatible instances

5.x series instances

  • 5.x series instances

  • 4.x series instances

  • 5.x series instances

  • 4.x series instances

  • 5.x series instances

  • 4.x series instances

4.x series instances

4.x series instances

When to use

The 5.x gRPC SDK is recommended.

  • Provides comprehensive support for multiple programming languages.

  • All new features and optimizations will be supported in the 5.x gRPC SDK.

  • If specific features of the 5.x gRPC SDK do not meet your requirements, consider using the 5.x Remoting SDK.

  • If your existing services already use these client versions, you can continue to use them.

  • 5.x series instances are compatible with these SDK versions.

  • These client versions are not recommended. These SDK versions will not support new features or optimizations.

  • These SDKs can access only 4.x series instances.

Sending normal, ordered, transactional, and scheduled messages

✅

✅

✅

✅

✅

✅

Concurrent consumption

✅

✅

✅

✅

✅

✅

Ordered consumption

✅

✅

✅

✅

✅

✅

Ordered consumption Optimize consumption concurrency

✅

❌

❌

❌

❌

❌

Broadcasting consumption

❌

✅

✅

✅

❌

❌

Stream consumption (connecting to services such as Flink)

❌

✅

✅

❌

❌

❌

Message trace

✅

✅

Supported in versions 4.5.2 and later

✅

✅

❌

Producer metrics and Consumer metrics client metrics

✅

❌

❌

❌

❌

❌

Graceful shutdown

✅

Supported only for 5.x series instances

❌

❌

❌

❌

SDK usage limits

  • Different consumers in the same ConsumerGroup must use clients that use the same protocol.

  • Take note of the following when you perform a phased upgrade from a Remoting protocol SDK to a gRPC protocol SDK within the same ConsumerGroup:

    • Consumer groups with ordered delivery do not currently support this upgrade.

    • Consumer groups with concurrent delivery support smooth upgrades. A small number of messages may be duplicated during the upgrade.

  • If all of the following steps (a, b, and c) are performed for a ConsumerGroup with ordered delivery, the consumer offset for ordered messages may be rolled back:

    1. The ordered ConsumerGroup initially runs with a Remoting protocol SDK.

    2. The SDK is upgraded to a gRPC protocol SDK to meet business requirements.

    3. The SDK is then rolled back to the Remoting protocol SDK.

  • The RocketMQ ONS TCP 2.x SDK is available only in some regions. For more information, see Compatibility and restrictions.

TCP protocol SDKs

Important

Use the Community Edition SDK only when migrating open source RocketMQ to the cloud without code changes. For all other scenarios, we recommend that you use the Enterprise Edition SDK provided by Alibaba Cloud ApsaraMQ for RocketMQ to connect to the service. Compared with the Community Edition SDK, the Enterprise Edition SDK provides more features and higher stability.

Enterprise Edition TCP protocol SDKs (ONS 1.x/2.x SDKs)

Community Edition TCP protocol SDKs (4.x/3.x SDKs)

HTTP protocol SDKs

Enterprise Edition HTTP protocol SDKs (recommended for multi-language support)

TCP vs. HTTP SDK comparison

TCP and HTTP protocol SDKs support different features. Evaluate the protocol type that you need in advance based on your business requirements.

SDK protocol type

TCP protocol SDK

HTTP protocol SDK

Selection recommendations

Recommended

  • Delivers high transmission performance and is suitable for high-concurrency scenarios.

  • Provides more comprehensive messaging features and faster iterations.

  • Provides richer observability metrics and more comprehensive message accumulation and consumer offset reset capabilities.

Alternative option

  • A supplementary option for multi-language integration. You can choose HTTP if TCP does not currently support your programming language.

  • Provides lightweight integration, involves fewer concepts, and is suitable for simple scenarios.

Normal messages

Supported

Supported

Ordered messages

Supported

Supported

Scheduled messages and delayed messages

Supported

Supported

Transactional messages

Supported

Supported

Delivery modes

Supported

Not supported

Delivery modes

Supported

Not supported

Batch consumption

Supported

Not supported

Clustering consumption and broadcasting consumption

Supported

Not supported

Clustering consumption and broadcasting consumption

Supported

Supported

Message retry

Supported

Supported

Query message traces

Supported

Supported

Dead-letter queues

Supported

Supported

Reset consumer offsets

Supported

Not supported

Usage notes

  • Endpoints for the HTTP and TCP protocols cannot be used interchangeably. For example, if you use a TCP protocol SDK to send and receive messages, you must obtain a TCP endpoint to connect to the ApsaraMQ for RocketMQ server.

  • ApsaraMQ for RocketMQ supports Group IDs for the HTTP and TCP protocols. Group IDs of different types cannot be used interchangeably. For example, if you use a TCP protocol SDK to send and receive messages, you must create a Group ID for the TCP protocol.

  • TCP and HTTP clients can send messages to and receive messages from each other. However, because HTTP uses XML serialization, message properties, content, Tag, Key, and other fields must comply with XML specifications. Otherwise, message sending or consumption may fail.

    You can use Base64 to encode and decode messages as needed when sending and receiving messages that do not comply with XML specifications.

    Note

    For more information about XML specifications, see XML syntax. You can also use the third-party tool xml_validator to validate XML syntax as needed.

  • TCP and HTTP provide public and private endpoints in all regions. By default, we recommend using a virtual private cloud (VPC) to access the service over a private network in production environments. If you need cross-region access, access from an on-premises data center (IDC), or Internet access and cannot currently use Cloud Enterprise Network (CEN) for networking, you can use a public endpoint to access the service. Public endpoints incur additional outbound Internet traffic fees. For more information, see Internet traffic pricing details.