ApsaraMQ for RocketMQ provides HTTP SDKs for multiple programming languages with public Internet access.
Support for multiple programming languages
ApsaraMQ for RocketMQ supports RESTful HTTP protocols and provides SDKs for seven programming languages. HTTP SDK features are continuously developed to align with TCP SDK features. For details about the differences, see the following topics:
Usage notes
-
HTTP consumers can use long polling or short polling to consume messages from ApsaraMQ for RocketMQ brokers.
-
Long polling: The consumer sends a request to the broker for messages in a specific topic. If no message exists, the broker holds the request until a message is produced or the long polling period elapses.
-
Short polling: If no message exists, the broker returns a response immediately. The client then repeatedly sends new subscription requests.
Configure the polling mode as follows:
-
Long polling: Set the
waitSecondsparameter to a value greater than 0 in the subscription request. The maximum value is 30 seconds. -
Short polling: Set the
waitSecondsparameter to 0 or leave it unspecified in the subscription request.
For more information, see Operation for consuming messages.
Short polling with no messages in the topic generates a large number of invalid requests, which incur API call fees. To reduce invalid requests and save costs, use long polling and increase the wait time. For information about API call fee calculation, see API call fees.
ImportantIf more than 100 consumers connect to an ApsaraMQ for RocketMQ instance over HTTP, the system automatically switches from long polling to short polling to ensure service stability and consumption timeliness. To prevent increased costs from invalid requests after this switch, limit the number of consumer connections.
-
-
HTTP SDK access is an enhanced feature of ApsaraMQ for RocketMQ. Self-managed Apache RocketMQ clusters do not support this feature.
-
Ensure that the resources you want to access are in the same region as the HTTP endpoint you use.
For example, if your ApsaraMQ for RocketMQ instance is in the China (Hangzhou) region, you must use the China (Hangzhou) endpoint. Note the following:
-
If your client is in the China (Hangzhou) region, use the HTTP internal endpoint for optimal performance.
-
If your client is outside the China (Hangzhou) region, ensure Internet connectivity and use the HTTP public endpoint.
-
-
Messages can be transmitted between TCP and HTTP clients. Because HTTP uses XML serialization, message attributes, bodies, tags, and keys must comply with XML rules.
NoteFor more information about XML rules, see XML syntax. You can also use the XML Validator tool to check compliance.
Characters that violate XML rules cause the following issues:
-
Messages sent over HTTP fail to send.
-
Messages sent over TCP and consumed over HTTP fail to be consumed.
To handle messages that contain non-compliant characters, use Base64 encoding and decoding.
-