ApsaraMQ for RocketMQ provides multi-language software development kits (SDKs) for the TCP and HTTP protocols. This topic describes the differences between the SDKs and explains how to use them.
SDK versions
The following table describes the features supported by different versions of ApsaraMQ for RocketMQ SDKs.
In the following table, ✅ indicates that the feature is supported, and ❌ indicates that the feature is not supported.
Item | ||||||
Protocol | gRPC protocol v2 | Remoting protocol | Remoting protocol | Remoting protocol | gRPC protocol v1 | HTTP protocol |
Accessible instances | 5.x series instances |
|
|
| 4.x series instances | 4.x series instances |
Recommendations | Use the 5.x gRPC SDK.
|
|
| |||
Sending normal, ordered, transactional, and scheduled messages | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Concurrent consumption | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Ordered consumption | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Consumption concurrency optimization for ordered consumption | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
Broadcasting consumption | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ |
Stream consumption (connecting to services such as Flink) | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
Message trace | ✅ | ✅ | Supported in versions 4.5.2 and later | ✅ | ✅ | ❌ |
✅ | ❌ | ❌ | ❌ | ❌ | ❌ | |
✅ | Supported only for 5.x series instances | ❌ | ❌ | ❌ | ❌ | |
SDK limits
All consumers in the same consumer group must use clients that support the same protocol.
When you perform a grayscale upgrade from a Remoting protocol SDK to a gRPC protocol SDK for the same consumer group, note the following:
Upgrades are not supported for consumer groups that deliver ordered messages.
Consumer groups that deliver messages concurrently support smooth upgrades. A small number of messages may be duplicated during the upgrade.
The consumer offset for ordered messages may be rolled back if you perform the following steps for a consumer group that delivers ordered messages:
The consumer group for ordered messages initially uses a Remoting protocol SDK.
You then upgrade the SDK to a gRPC protocol SDK.
You roll back the SDK to the Remoting protocol SDK.
The RocketMQ ONS TCP 2.x SDK is available only in some regions. For more information, see Limits.
TCP protocol
Use the Community Edition SDK only when you migrate open source RocketMQ to the cloud and do not want to modify your code. For all other scenarios, use the Enterprise Edition SDK provided by ApsaraMQ for RocketMQ. Compared with the Community Edition SDK, the Enterprise Edition SDK provides more features and ensures higher stability.
Enterprise Edition TCP protocol SDKs (ONS 1.x/2.x SDKs)
HTTP protocol
Enterprise Edition HTTP protocol SDKs (recommended for multi-language support)
Python SDK
Node.js SDK
Comparison between TCP and HTTP protocol SDKs
TCP and HTTP protocol SDKs support different features. Evaluate which protocol type best suits your requirements.
SDK protocol type | TCP protocol SDK | HTTP protocol SDK |
Recommendation | Recommended choice
| Alternative choice
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
SDK usage notes
Each type of endpoint can be used only by clients of the same protocol type. For example, if you want to use a TCP client SDK to send and receive messages, you must use the TCP endpoint of your ApsaraMQ for RocketMQ instance to access the ApsaraMQ for RocketMQ broker.
ApsaraMQ for RocketMQ supports group IDs for the HTTP and TCP protocols. Group IDs for different protocols cannot be used interchangeably. For example, if you use a TCP protocol SDK to send and receive messages, you must create a TCP protocol group ID.
Clients that use the TCP protocol and clients that use the HTTP protocol can send messages to and receive messages from each other. However, the HTTP protocol uses XML to serialize messages. Therefore, message properties, content, tags, and keys must comply with XML specifications. Otherwise, messages may fail to be sent or consumed.
You can use Base64 to encode and decode messages that do not comply with XML specifications.
NoteFor more information about XML specifications, see XML syntax. You can also use a third-party tool, such as xml_validator, to check whether the XML syntax is valid.
Public and private endpoints for TCP and HTTP clients are provided in all regions. In production environments, we recommend that you access ApsaraMQ for RocketMQ in virtual private clouds (VPCs). If you want to access ApsaraMQ for RocketMQ across regions, from on-premises data centers, or over the Internet while Cloud Enterprise Network (CEN) is unavailable, you can use public endpoints to access ApsaraMQ for RocketMQ instances. If you use public endpoints to access ApsaraMQ for RocketMQ instances, you are charged for outbound Internet traffic. For more information, see Billing of Internet traffic.