Updated on 2026-04-30 GMT+08:00

Configuring a RocketMQ Client

Suggestions on configuring a RocketMQ client.

Java Client Version

5.1.4 and later are recommended.

Unique ClientId

By default, ClientId combines the process ID, local IP address, and instance name. When two consumers in a consumer group are started in a process, their ClientIds are the same. As a result, some queues are repeatedly consumed and others cannot be consumed.

Recommended Setting

ClientId is generated with clientIP of a consumer. If different consumers share a clientIP at the same IP address, ClientId will be the same. You are advised to add the following code to manually set instanceName.
consumer.setInstanceName(String.valueOf(System.nanoTime()))

Producer Exception Detection

Available in Java client 5.1.4 and later.

Enable exception detection on a client. When accessing a broker times out, the client can quickly switch to another broker for message production.

producer.setSendLatencyFaultEnable(true)

Error Code SYSTEM_BUSY for Producer Retry

Producers are advised to configure error codes for retry. When SYSTEM_BUSY is returned due to exceptions such as busy disk writing or master/slave switchover, resending messages to other normal brokers can reduce service impact.
producer.addRetryResponseCode(ResponseCode.SYSTEM_BUSY);

Function addRetryResponseCode is available only for client 4.9.2 and later. Note that SYSTEM_BUSY is added by default for client 5.2.1 and later.

Obtaining SDK Logs

The communication protocol between the RocketMQ client and server is complex. For example, the allocation of consumption queues and addressing of topics are determined by the client SDK. Important information about these processes is stored in SDK logs. When a production or consumption problem occurs, SDK logs are one of the most important methods for troubleshooting. Therefore, you must save these logs. Generally, SDK logs and service logs are not printed in the same file. Table 1 lists the default paths of common SDK logs.

Table 1 Default paths of SDK logs

SDK Language

Protocol

Path

Java

TCP

~/logs/rocketmqlogs/rocketmq_client.log

Java

gRPC

~/logs/rocketmq/rocketmq_client.log

Go

TCP

/tmp/rocketmq-client.log

Go

gRPC

~/logs/rocketmqlogs/rocketmq_client_go.log