1 Answers

12
votes

The google.cloud.pubsub library is designed to be make it easy to get the best performance out of a Cloud Pub/Sub publisher and subscriber. It has more advanced features such as message batching, asynchronous message delivery, and automatic ack deadline extension for messages not yet acknowledged by a subscriber. The API is different from the underlying Cloud Pub/Sub service API. For example, this library does not expose the pull method directly; messages are instead delivered to a callback passed into the subscriber's open method.

The google.cloud.pubsub_v1 library exposes the underlying API directly. It can be useful in specific cases where this level of control is necessary, e.g., when a synchronous subscriber is required in order to make requests in response to synchronous actions from a downstream dependency.

When possible, it is best to use the google.cloud.pubsub library.