Skip to content

Publisher : Lifetime of the publisher object (Pubsub) #2342

Description

@hmigneron

When using the pubsub java client, how long should a Publisher object live for ?

In a scenario where we get frequent HTTP requests that get translated into Pubsub messages, doing

try {
    publisher = Publisher.defaultBuilder(topic).build();

    //... do publish stuff
}
finally { 
    if (publisher != null) {
        publisher.shutdown();
    }
}

each time seems inefficient. I couldn't find any documentation on the expected lifetime of the object.

How often should the publisher be shutdown (either in terms of time or messages published) ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions