All Products
Search
Document Center

:FAQ about message consumption

Last Updated:Oct 11, 2023

How do I troubleshoot the issue that connection fails the first time I connect my client to the broker?

Check whether the following configurations are valid:

  • Check whether the endpoint is correctly specified. You can obtain the endpoint on the Instance Details page in the ApsaraMQ for RocketMQ console.

  • Run the telnet Endpoint domain name Port number command to check the network connectivity.

    • If your application is deployed on an on-premises machine or if you want to access ApsaraMQ for RocketMQ across regions but cannot build a network by using Cloud Enterprise Network (CEN), you must use a public endpoint to access the ApsaraMQ for RocketMQ instance. If you use a public endpoint to access an ApsaraMQ for RocketMQ instance, you are charged for outbound Internet traffic. For more information, see Internet traffic fee for ApsaraMQ for RocketMQ 4.x instances or Internet traffic fee for ApsaraMQ for RocketMQ 5.x instances.

    • If your application is deployed on an Alibaba Cloud Elastic Compute Service (ECS) instance, you can use a virtual private cloud (VPC) endpoint to access the ApsaraMQ for RocketMQ instance in a VPC. In this case, you must make sure that the ECS instance resides in the same region as the ApsaraMQ for RocketMQ instance

  • If you enable the Internet access feature for an ApsaraMQ for RocketMQ 5.0 instance, check whether an IP address whitelist is configured. If you enable the Internet access feature, you can access ApsaraMQ for RocketMQ by using any IP address by default. If you specify an IP address whitelist, you can access ApsaraMQ for RocketMQ by using only the IP addresses in the whitelist.

  • Check whether the topic name is correctly specified. Make sure that the topic is created in the ApsaraMQ for RocketMQ console, and the topic name does not contain extra spaces or special characters.

  • Check whether the username and password are correctly specified.

    • ApsaraMQ for RocketMQ 5.0 instances: You must specify the username and password of the instance. You can obtain the instance username and password on the Instance Details page in the ApsaraMQ for RocketMQ console.

    • ApsaraMQ for RocketMQ 4.0 instances: You must specify the AccessKey ID and AccessKey secret of the Alibaba Cloud account or Resource Access Management (RAM) user. If you use a RAM user, make sure that the RAM user is granted the required permissions. For information about how to obtain an AccessKey pair, see Create an AccessKey pair.

What do I do if subscriptions are inconsistent?

Log on to the ApsaraMQ for RocketMQ console. On the Groups page, view the subscriptions and consumers of the consumer group in which the issue occurs. Then, modify the subscription code of the consumers whose subscriptions are inconsistent.

How do I handle accumulated messages?

Messages may be accumulated due to the following causes:

  • An exception occurred in the message consumption logic.

  • Traffic spikes occurred in the application that produces messages. In this case, the rate of message production far exceeds the rate of message consumption and message accumulation is caused.

  • The processing duration of the downstream services on which consumers rely is prolonged, and consumption threads are blocked.

  • Insufficient consumption threads cause a low level of consumption concurrency. As a result, message consumption lags behind message production.

To determine the cause of an exception, you must check the logs or stack information of the client. For more information, see How do I handle accumulated messages?

What do I do if a consumer cannot consume messages?

  1. Log on to the ApsaraMQ for RocketMQ console. On the Groups page, check whether the consumer is online and whether the client connection is normal. If the client is not connected, check the client logs and troubleshoot the exception based on the error.

  2. Check whether the subscriptions are consistent. If the subscriptions are inconsistent, find the consumer client whose subscriptions are inconsistent based on the distribution of the subscriptions and modify the subscription code of the consumer client.

Are messages lost if the machine on which a consumer group runs fails and restarts?

ApsaraMQ for RocketMQ provides persistent subscriptions. If a consumer group goes offline or a consumption exception occurs, messages are not lost. After the consumer client is reconnected to the broker, a consumer can consume messages from the offset where the consumer left off before the client was disconnected.

Can I leave the parameter that is used to specify tags empty when I subscribe to messages?

No. If you leave the parameter that is used to specify tags empty when you subscribe to messages, consumers cannot consume messages. If you want to subscribe to all messages in a topic, you must set the parameter to *. Sample code:

String topic = "Your Topic";
// Use tags to filter messages and subscribe to all messages. 
FilterExpression filterExpression = new FilterExpression("*", FilterExpressionType.TAG);
pushConsumer.subscribe(topic, filterExpression);

For more information, see Tag-based filtering.

How do I set the consumer offset if I create a consumer group to subscribe to an existing topic?

When you create a consumer group, you cannot set the consumer offset, regardless of whether you subscribe to a new topic or an existing topic. If a consumer is started for the first time, consumption starts from the earliest stored message by default.

If a consumer is not started for the first time, you can reset the consumer offset in the ApsaraMQ for RocketMQ console. For more information, see Reset a consumer offset.