google-cloud-pubsub

Behaviour of NACKED message in PubSub


In the documentation we can find this:

Negatively acknowledged messages (nacked). Nacking a message by a subscriber causes Pub/Sub to redeliver it immediately. When a subscriber nacks messages that are invalid or when it cannot process the messages, the subscriber helps ensure that these messages are not lost and that they are eventually processed successfully. You can use modifyAckDeadline with a value of 0 to nack a message.

Do nacked messages in PubSub go back to the subscriber's queue for redelivery and behave as other messages, or do they have a specific priority when being pulled again?

"redeliver it immediately" Suggests that they are redelivered to handlers before other messages in the queue


Solution

  • Nacked messages do not have a special priority over other messages that were published. They do tend to be cached in a way that makes them more likely to be redelivered right away, but there are no guarantees around it.