SubscriberClient.pull-如何取消请求? [英] SubscriberClient.pull - how to cancel a request?

查看:120
本文介绍了SubscriberClient.pull-如何取消请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

公共最终PullResponse pull(SubscriptionName subscription,boolean returnImmediately,int maxMessages)

public final PullResponse pull(SubscriptionName subscription, boolean returnImmediately, int maxMessages)

根据文档:

@param returnImmediately如果此字段设置为true,即使Pull响应中没有可返回的消息,系统也会立即响应.否则,系统可能会等待(一定时间),直到至少有一条消息可用,而不是不返回任何消息.

@param returnImmediately If this field set to true, the system will respond immediately even if there are no messages available to return in the Pull response. Otherwise, the system may wait (for a bounded amount of time) until at least one message is available, rather than returning no messages.

如果客户不想再等待响应,则可以取消该请求.

The client may cancel the request if it does not wish to wait any longer for the response.

我有一个调用pull的线程,其中returnImmediately标志设置为false. 如果我中断线程,在拉取请求超时之前会有一个(大约60秒)的延迟,我可以检查中断的标志状态.

I have a Thread that calls pull, with the returnImmediately flag set to false. If I interrupt() the thread there is a (roughly 60 second) delay before the pull request times out and I can check the interrupted flag status.

我看不到将中断请求传递给呼叫的任何方法.我也没有找到一种配置有限时间"的方法.我想念什么?

I don't see any way to pass an interrupt request to the call. Nor do I see a way to configure the "bounded amount of time". What am I missing?

推荐答案

您似乎使用的是旧版的Alpha Google Cloud Pub/Sub客户端库.在版本≥0.11.0中(包括

It looks like you may be using a fairly old version of the alpha Google Cloud Pub/Sub client library. In versions ≥ 0.11.0 (including the latest version, 0.17.1), the inconsistency no longer exists as the API has been altered such that you no longer need to worry about returnImmediately.

这篇关于SubscriberClient.pull-如何取消请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆