Search code examples
google-cloud-platformgoogle-cloud-pubsub

How to delay re-delivery message?


I am using the asynchronous pull of Cloud Pub/Sub

For now, when I call message.nack() method, it will re-delievery this message immediately.

subscription.on('message', (message) => {
  message.nack();
})

How to delay the re-delivery?

For example, I got a message with publishTime: '2019-05-28T10:24:31.055Z'

I want to let this message re-delivery 20 seconds(computed) later from last delivery.


Solution

  • There is currently no way in Cloud Pub/Sub to delay the redelivery of a message. When a message is nacked, it is immediately a candidate for redelivery to the same subscriber or to another subscdriber.