Status inconsistency

更新时间: 2026-03-28 14:59:21

This topic describes common status inconsistency issues and their solutions.

Unexpected client connections

Symptoms:

  • Clients do not receive some messages after they are sent. When you query messages by message ID, you find that some messages are sent to the broker but not delivered to downstream consumers. For more information, see Message query.

  • When you view the consumer status for the target Group ID, you find unexpected client IPs in the connection information. Some messages are stacked only on these unexpected clients. For more information, see View consumer status.

Possible cause:

A client for the Group ID was started with incorrect configurations, such as an incorrect AccessKeyId, AccessKeySecret, or Topic. The client process then occupies some message queues for the topic but cannot consume messages correctly. As a result, messages are stacked on the server-side and cannot be delivered in real time to the correct downstream consumers.

Solution:

  1. Locate the problematic process based on its connection status. Then, check the /{user.home}/logs/sofamq.log file and your program code to confirm that the AccessKey (AK), SecretKey (SK), Topic, and other information are configured correctly.

  2. Quick recovery.

    For a quick recovery, shut down the problematic client process. The stacked messages are then immediately rebalanced and delivered to the healthy clients. After you fix the issue, restart the problematic process.

Verification:

Log on to the Message Queue console and view the consumer status for the target Group ID. Confirm that the connection information lists only expected clients and that they can consume messages. The Consistent Subscription Relationship column must display Yes.

Invalid messages

Possible causes:

The message attributes or message content are invalid. This can happen in the following four cases:

  • The message is empty.

  • The message content is empty.

  • The message content has a length of 0.

  • The message content exceeds the maximum allowed length.

Solution:

Ensure that the message does not meet any of the invalid conditions listed above. Resolve the issue based on the exception message.

Invalid parameters

Possible causes:

Nested exception description

Exception description

consumeThreadMin Out of range [1, 1000]

The number of consumer threads is set incorrectly.

consumeThreadMax Out of range [1, 1000]

The number of consumer threads is set incorrectly.

messageListener is null

The messageListener is not set.

consumerGroup is null

The Group ID is not set.

msg delay time more than 40 day

The delay for a scheduled message cannot exceed 40 days.

Solution:

  1. Ensure that the client parameters do not meet any of the invalid conditions listed above. Resolve the issue based on the exception message.

  2. Restart the application.

Abnormal client status

Possible causes:

  • The start() method was not called to start the client after the Consumer or Producer was created.

  • An exception occurred during the start() process after the Consumer or Producer was created, causing the client to fail to start.

  • The shutdown() method was explicitly called to shut down the client after the client was created and successfully started.

Solution:

Check the ons.log file to determine if any exceptions occurred during the client startup process.

Inconsistent subscription relationships

Possible cause:

You started multiple Consumers in different Java Virtual Machines (JVMs). You then configured these consumers to use the same Group ID but different Topics, or the same Topic but different Tags. This results in inconsistent subscription relationships, and messages are not consumed as expected.

  • Incorrect example 1:

    The same Group ID (GID-MQ-FAQ) subscribes to different Topics (MQ-FAQ-TOPIC-1 and MQ-FAQ-TOPIC-2).

    • The following code is an example for JVM-1:

      Properties properties = new Properties();
      properties.put(PropertyKeyConst.GROUP_ID,"GID-MQ-FAQ");
      Consumer consumer=ONSFactory.createConsumer(properties);
      consumer.subscribe("MQ-FAQ-TOPIC-1","NM-MQ-FAQ",new MessageListener(){
          public Action consume(Message message,ConsumeContext context){
              System.out.println("Receive: "+message);
              return Action.CommitMessage;
          }
      });
      consumer.start();

    • The following code is an example for JVM-2:

      Properties properties = new Properties();
      properties.put(PropertyKeyConst.GROUP_ID,"GID-MQ-FAQ");
      Consumer consumer=ONSFactory.createConsumer(properties);
      consumer.subscribe("MQ-FAQ-TOPIC-2","NM-MQ-FAQ",new MessageListener(){
          public Action consume(Message message,ConsumeContext context){
              System.out.println("Receive: "+message);
              return Action.CommitMessage;
          }
      });
      consumer.start();
      
  • Incorrect example 2:

    The same Group ID (GID-MQ-FAQ) subscribes to the same Topic but with different Tags (NM-MQ-FAQ-1 and NM-MQ-FAQ-2).

    • The following code is an example for JVM-1:

      Properties properties =new Properties();
      properties.put(PropertyKeyConst.GROUP_ID,"GID-MQ-FAQ");
      Consumer consumer =ONSFactory.createConsumer(properties);
      consumer.subscribe("MQ-FAQ-TOPIC-1","NM-MQ-FAQ-1",new MessageListener(){
        public Action consume(Message message,ConsumeContext context){
            System.out.println("Receive: "+ message);
            return Action.CommitMessage;
        }
      });
      consumer.start();

    • The following code is an example for JVM-2:

      Properties properties =new Properties();
      properties.put(PropertyKeyConst.GROUP_ID,"GID-MQ-FAQ");
      Consumer consumer =ONSFactory.createConsumer(properties);
      consumer.subscribe("MQ-FAQ-TOPIC-1","NM-MQ-FAQ-2",new MessageListener(){
          public Action consume(Message message,ConsumeContext context){
              System.out.println("Receive: "+ message);
              return Action.CommitMessage;
          }
      });
      
      consumer.start();

Solution:

When you start multiple Consumers with the same Group ID in different JVMs, ensure that their Topic and Tag configurations are consistent.

上一篇: Resource does not exist 下一篇: Application out of memory
阿里云首页 金融分布式架构 相关技术圈