Kamil Janowski
Kamil Janowski

Reputation: 2025

Can I specify ttl for Pub/Sub messages?

I found in the Google Pub/Sub documentation that a published message can wait for up to 7 days for the delivery to the subscriber and then it gets deleted. But is there a way to make this time shorter, like 10 seconds? Perhaps some message attribute or subscription configuration?

Upvotes: 2

Views: 2341

Answers (1)

Kamal Aboul-Hosn
Kamal Aboul-Hosn

Reputation: 17251

The feature to allow one to change the retention time to make it shorter than 7 days is currently an alpha feature and cannot be set via the UI, but it can be set via the gcloud command-line tool. The shortest retention duration allowed is 10 minutes. To set this property, run the following:

gcloud alpha pubsub subscriptions update \
projects/<project>/subscriptions/<subscription> \
--message-retention-duration=10m

Upvotes: 4

Related Questions