谷歌PubSub拉动超时与.setReturnImmediately(false)

时间:2016-07-20 07:25:11

标签: google-cloud-platform google-cloud-pubsub

是否可以使用setReturnImmediately(false)为拉模式设置自定义超时?

当前超时为20秒。

使用Google Cloud Services API客户端Java库。

1 个答案:

答案 0 :(得分:0)

    HttpRequestInitializer customInit = (request) -> {
            credential.initialize(request);
            request.setConnectTimeout(3000);
            request.setReadTimeout(3000);
    };


    Pubsub.Builder builder = new Pubsub.Builder(TRANSPORT, 
                                                JSON_FACTORY, 
                                                credential)
            .setHttpRequestInitializer(customInit)
            .setApplicationName("app-name");