SDK reference overview
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 | ||||||
Protocol | gRPC protocol v2 | Remoting protocol | Remoting protocol | Remoting protocol | gRPC protocol v1 | HTTP protocol |
Compatible instances | 5.x series instances |
|
|
| 4.x series instances | 4.x series instances |
When to use | The 5.x gRPC SDK is recommended.
|
|
| |||
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 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
✅ | 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:
The ordered ConsumerGroup initially runs with a Remoting protocol SDK.
The SDK is upgraded to a gRPC protocol SDK to meet business requirements.
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
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)
Python SDK
Node.js SDK
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
| Alternative option
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
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.
NoteFor 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.