Message Consumption

Last Updated on : 2024-06-14 09:30:55download

After messages are successfully pushed to the Pulsar server, you can get the messages for processing through the locally started Pulsar consumer and report the consumption results.

Message consumption

Unconsumed messages are retained for two hours.
After a message is pushed to the Pulsar server, the server will retain it for two hours. During this period, the message can be obtained and consumed. After this period, the message will be discarded and deleted from the server.

Consumption Description
Message is consumed successfully The message has been processed by the consumer and the result is reported successfully.
Message is not consumed The message has not been processed by the consumer, or a successful result has not been reported.
Message is expired and deleted The message has been retained for more than two hours and has not been successfully consumed, so it is deleted from the server.

Message is not consumed

Description

  • The message is retained in the system for less than two hours.
  • The consumer has not yet reported a successful consumption result.

Cause

Go to Cloud, select the target project, and then choose Open Project > Message Service > Subscription Management. Depending on the channel type of the message, you can switch to the production environment or test environment to view the subscription list. Possible causes:

  • The Pulsar consumer is not started. You can check whether the status of a specific subscription is good, whether there is a button (+) to expand the consumer list, or whether the expanded consumer list is proper.
  • The Pulsar consumer consumes messages slowly, resulting in a large accumulation of messages. For example, your local consumption process relies on external services, or the API call is too slow. You can check whether the accumulation of specific subscribed messages is greater than 0. You can also click Monitor in the subscription to check whether the recent consumption rate is slow.
  • Devices reporting a large amount of data in a short period can generate many messages. You can check whether the accumulation of specific subscribed messages is greater than 0. You can also click Monitor in the subscription to check whether the recent production rate is too high.

Solutions

After performing the following steps, you can go to Cloud, select the target project, and then choose Open Project > Message Service > Subscription Management. Depending on the channel type of the message, you can switch to the production environment or test environment to verify. You can also click Monitor in the subscription to check whether the consumption rate is improved.

  • For scenarios where the consumer is not started, you can refer to the Best Practices, select the suitable programming language, and then configure and start the Pulsar consumer. After the consumer is started successfully, you can check whether the status of the specific subscription is good. Click + to expand the consumer list and check whether the consumer list and the IP addresses in it are proper.
  • For scenarios where messages are accumulated, if the message volume surges in the short term, you can observe whether the amount of messages significantly declines as time goes by. If the amount of accumulated messages does not decline or the consumption rate is slow, you can add Pulsar consumers to speed up the consumption. By default, in the production environment, 11 Pulsar consumers can be started to achieve the maximum consumption rate.

Message is expired and deleted

Description

The consumer has not yet reported a successful consumption result and the messages are retained for more than two hours.

Cause

Refer to the cause of why a message is not consumed.

Solutions

Refer to Solutions for a message is not consumed.