-
Hello everyone, I was wondering if and how I can pause polling on a subscription without actually cancelling it. I am using a subscriber with concurrency set to 1 and my own completion queue thread so I only ever execute one handler at a time. Normally this means I intend to receive messages as soon as this thread is idle or done executing a handler. One message at a time, as quick as possible and as soon as one comes in.
So, I know I can call cancel() on the future to stop the subscriber. But what what if I only need to pause it for half a second or so? I suppose it's quite inefficient to cancel the subscriber and recreate it when I need to continue, so I'm looking for a less intrusive method to pause execution. Since the API doesn't seem to have something to that effect I thought perhaps one could inhibit the completion queue somehow and then continue it? Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Note that strictly speaking this is not polling. The underlying RPC is a streaming RPC, that means the service will push messages before you ask for them, subject to whatever flow control settings you configured. That is important to understand, because pausing on the client side will not stop the message from being assigned to your client. With that out of the way. I think the key requirement on what you want is
I realize this may not be what you want: you could delay delivery of the next message by delaying the ack for any previous message. For example, if you set the flow control options to deliver a single message at a time: google-cloud-cpp/google/cloud/pubsub/options.h Lines 225 to 227 in c1ce073 Then the service will not send more messages until you That allows you to pause, but I suspect you want to pause before the message is sent? I do not think we can do this with the current RPCs used by the library. By the time your client applications decides to "pause" the service may have already sent a message. I think we would need something more like #7187 where we can pull messages one at a time. I thought maybe changing the flow control settings dynamically, but that is not allowed: Sorry I don't have a good answer and thanks for your excellent questions. Do let me know if #7187 would help, customers asking for features is one of the main inputs for sequencing our work. |
Beta Was this translation helpful? Give feedback.
OK... I guess I misunderstood the visibility timeout then. When I create a subscription (SDK or Web Console) the maximum value is 600s. I was under the impression that is the absolute maximum a message can be "leased" (aka received and be invisible to other receivers) and after 600s the message will be received by others no matter if I ack or nack it. I can't sa…