Reputation: 17258
I'm subscribing to data using subscribe()
(below).
Occasionally I receive messages out of order and I disregard them, hoping for them to be redelivered 'soon'.
Is there a way to set the ackDeadline
from subscribe()
? I can only see it available for streaming_pull()
.
Code:
subscriber = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path(project_id, subscription_id )
streaming_pull_future = subscriber.subscribe(subscription_path, callback=callback)
Upvotes: 0
Views: 246
Reputation: 17251
It sounds like you are wanting to delay redelivery of the message so you can process it at some point in the future. If that is the case, what you want to do is set a retry policy on your subscription (see "Retry policy" in the subscription properties). This will cause Cloud Pub/Sub to exponentially back off delivery of messages that are nacked. Then, within the code in callback, you can nack a message by calling message.nack()
.
Note that Cloud Pub/Sub does offer ordered delivery, which might be a better fit if you want to process messages in order rather than nack and wait for redelivery in order.
Upvotes: 1