The Java SDK provided by Message Queue for Apache RocketMQ allows you to send and subscribe to messages. This topic describes the parameters in the message sending and subscription interfaces.

Common parameters

Parameter Description
NAMESRV_ADDR The TCP endpoint. You can obtain it on the Instance Details page in the Message Queue for Apache RocketMQ console.
AccessKey The AccessKey ID you created in the Alibaba Cloud console for identity authentication.
SecretKey The AccessKey secret that you created in the Alibaba Cloud console for identity authentication.
OnsChannel The user channel, which is ALIYUN by default and CLOUD for CloudTmall users.

Message sending interface

messagesendinterface

Message sending parameters

Parameter Description
SendMsgTimeoutMillis The message transmission timeout interval, in milliseconds. Default value: 3000.
CheckImmunityTimeInSeconds (for transactional messages) The shortest time interval (in seconds) before the first recheck of a transactional message.
shardingKey (for ordered messages) The shard key for ordered messages.

Message subscription interface

messageconsumeinterface

Message subscription parameters

Parameter Description
GROUP_ID The group ID you created in the Message Queue for Apache RocketMQ console.Terms
MessageModel The consumption pattern of a consumer instance. Valid values:
  • CLUSTERING (default): clustering consumption
  • BROADCASTING: broadcasting consumption
ConsumeThreadNums The number of consumption threads for a consumer instance. Default value: 20.
MaxReconsumeTimes The maximum number of retries upon a consumption failure. Default value: 16.
ConsumeTimeout The maximum consumption timeout interval for each message. If a message fails to be processed within this interval, the consumption fails, and the message needs to be re-sent for consumption. An appropriate value (in minutes) must be set for each business. Default value: 15.
suspendTimeMillis (for ordered messages) The retry interval for ordered messages that fail to be consumed.
maxCachedMessageAmount The maximum number of messages cached on the local client. Default value: 1000.
maxCachedMessageSizeInMiB The maximum size of messages cached on the local client. Value range: 16 MB to 2 GB. Default value: 512 MB.

References

Sample code for the transmission and reception of messages