API reference and parameter descriptions

更新时间: 2026-04-01 16:07:38

SOFAStack Message Queue provides a Java software development kit (SDK) to send and subscribe to messages. This topic describes the parameters for the message sending and subscription APIs.

Common parameters

Parameter

Description

ENDPOINT

The TCP protocol endpoint. Obtain this from the Overview > Endpoint Configuration page in the Message Queue console.

INSTANCE_ID

The instance ID. Obtain this from the Overview > Endpoint Configuration page in the Message Queue console.

ACCESS_KEY

The AccessKeyId that you create in the Alibaba Cloud account management console. It is used for identity authentication.

SECRET_KEY

The AccessKeySecret that you create in the Alibaba Cloud account management console. It is used for identity authentication.

Message sending API

Sending messages

Message sending parameters

Parameter name

Description

SEND_MSG_TIMEOUT_MILLIS

The timeout period for sending a message, in milliseconds. The default value is 3000.

shardingKey (ordered message)

For ordered messages, this is the value used to calculate the partition.

Message sending return values

  • SendResult for sync messages

    Struct parameter

    Description

    messageId

    The message ID. You can use the message ID to query the message trace in the console. If the message fails to be sent, no message ID is returned.

    topic

    The message topic.

  • SendResult for asynchronous messages

    Struct parameter

    Description

    onSuccess

    If the message is sent successfully, the method implemented in `onSuccess` is executed.

    onException

    If an exception is thrown when sending the message, the method implemented in `onException` is executed.

Message subscription API

Subscribing to messages

Message subscription parameters

Parameter name

Description

GROUP_ID

The Group ID that you create in the Message Queue console. For more information, see Glossary.

MESSAGE_MODEL

The consumption mode of the consumer. Valid values:

  • CLUSTERING (default): clustering consumption.

  • BROADCASTING: broadcasting consumption.

CONSUME_THREAD_NUMS

The number of consumer threads. The default value is 20.

MAX_RECONSUME_TIMES

The maximum number of retries for a failed message consumption. The default value is 16.

CONSUME_TIMEOUT

The maximum timeout period for consuming a single message. If this period is exceeded, the consumption is considered failed, and the message is redelivered for consumption. Set a reasonable value based on your service needs. Unit: minutes. The default value is 15.

SUSPEND_TIME_MILLIS (ordered message)

This parameter applies only to ordered messages. It specifies the retry interval for a failed message consumption.

MAX_CACHED_MESSAGE_AMOUNT

The maximum number of messages that can be cached on the client. The default value is 1000.

MAX_CACHED_MESSAGE_SIZE_IN_MI_B

The maximum size of messages that can be cached on the client. The default value is 512 MB. The value can range from 16 MB to 2 GB.

More information

Code examples for sending and receiving messages

上一篇: Demo project 下一篇: Prepare the environment
阿里云首页 金融分布式架构 相关技术圈