Usage issues
This section describes common issues that you may encounter when using Message Queue and provides the corresponding solutions.
Client fails to start with a "Cannot find name server with endpoint" error
Producer or consumer fails to start due to a duplicate Group ID
Failed to retrieve the queue list when subscribing to messages
Message status is 'Consumed' but the consumer does not receive it
Cannot connect to a broker
Possible causes:
The Alibaba Cloud Elastic Compute Service (ECS) instance that you are using is not in the same region as the Message Queue server.
You are accessing the Message Queue service from a server that is not on Alibaba Cloud, and the topic that you created does not support access from outside Alibaba Cloud.
Solution: Make sure that the ECS instance and the topic are in the same region.
Client fails to start with a "Can not find name server with endpoint" error
Possible cause: The instanceId, dataCenter, or endpoint parameters are incorrect. The client filters the sofamqnamesrv addresses returned by the Access Controller Virtual IP (ACVIP) address based on the dataCenter parameter.
Solution:
Verify the instanceId, dataCenter, and endpoint parameters.
Send a direct request to the ACVIP and check the returned data. The data is incorrect if either of the following situations occurs:
curl --location --request POST 'http://{replace_with_your_acvip_endpoint}:9003/antcloud/antvip/instances/get' \ --header 'Content-Type: application/json' \ --data '{"allowPolling" : false,"from": "sofamq-client","clientVersion": "direct_http_json","vipDomainName2ChecksumMap": {"{replace_with_your_instanceId}-SOFAMQ": "N"}}'The returned address list is empty. This indicates that you have not enabled SOFAStack Message Queue in the console, and the address has not been added to the corresponding ACVIP domain name.
The returned address list is not empty, but the dataCenter property of each returned address does not match the dataCenter value that you configured. To find the correct dataCenter value, log on to Yunyou Local and navigate to Environment Settings > Environment Variables > datacenter.
Producer or consumer fails to start due to a duplicate Group ID
Possible cause: Multiple producer or consumer instances that use the same Group ID are started in the same Java Virtual Machine (JVM) process. This causes the client to fail to start.
Solution:
In the same JVM process, start only one producer instance and one consumer instance for a specific Group ID. Do not start multiple producer or consumer instances that use the same Group ID in the same process.
Restart the application.
Failed to get the queue list when subscribing to messages
Possible cause: The topic may not have been created in the console. This causes the subscriber to fail to retrieve the topic's queue information at startup.
Solution:
Log on to the Message Queue console. In the navigation pane on the left, choose Topic Management > Create Topic, and then create a topic. For more information, see Create a topic.
In the navigation pane on the left, choose Group Management > Create Group ID, and then create a Group ID. For more information, see Create a Group ID.
Restart the application.
Message status is 'Consumed' but the consumer does not receive it
Possible causes:
Your business code does not immediately log the message after receiving it.
After a message is received, it may be processed directly by your business logic. In this case, a logic branch may be missed, which prevents the message information from being recorded in the business log. This can create the false impression that the message was not received. To avoid this issue, immediately log message information, such as messageId, timestamp, and reconsumeTime, after you receive a message.
Multiple consumer instances are deployed.
During the debug phase, the consumer is often restarted multiple times. If multiple consumer processes exist at the same time because a previous process did not exit correctly, the application enters cluster consumption mode. In this mode, multiple consumer instances share the load of consuming messages. A message that appears to be missing may have been received by another consumer instance.
Log on to the Message Queue console and navigate to Group Management > Consumer Status > Connection Status. You can view the deployment details of the consumer instances, such as the number of instances and their IP addresses, to help you troubleshoot the issue.
An uncaught exception occurs during message consumption, which causes the message to be redelivered.
public class MessageListenerImpl implements MessageListener { @Override public Action consume(Message message, ConsumeContext context) { // If the message processing logic throws an exception, the message will be retried. doConsumeMessage(message); // If an uncaught exception occurs in the doConsumeMessage() method, this log entry will not be printed. log.info("Receive Message, messageId:", message.getMsgID()); return Action.CommitMessage; } }
If the issue persists, provide the local software development kit (SDK) logs and submit a ticket for technical support.