Search code examples
google-cloud-platformpublish-subscribegoogle-cloud-pubsub

Is there a way to delete a message from pubsub message store?


I am using GCP Pubsub to send and receive JSON data, Pubsub has a feature to retain a message from a time period of 10 minutes up to 7 days and not less than 10 minutes (according to the official documentation). Is there any way to delete a pulled message from Pubsub? If not, then why do we say that Pubsub is a "Queuing technique" when we willingly cannot delete a message from a message store which violates a basic queue property?

I am using python Pubsub client library for the scripting purpose.


Solution

  • Messages are retained by Google Cloud Pub/Sub under two conditions:

    1. The message has not yet been acknowledged for a subscription and the retention duration has not passed.
    2. retainAckedMessages is enabled and the retention duration has not passed.

    Once you have received a message and called ack on it within the ack deadline, the message will no longer be redelivered for that subscription (other than duplicates that can happen given that Pub/Sub has at-least-once delivery semantics).