Skip to content

Pub/Sub subscriptions don't bind to the specified topic as stated in documentation #2341

@georgegiovanni

Description

@georgegiovanni

Page Name: pubsub-topic
Release: 0.18.1

Can a helper subscription method be added in the gcloud.pubsub.client.Client class to facilitate subscribing to subscriptions similar to how there's a topic method to facilitate creating topics. Current instructions for receiving pull messages suggest invoking the gcloud.pubsub.topic.Topic.subscription method which creates a subscription bound to the specified topic as follows:

pubsub_client = pubsub.Client()
topic = pubsub_client.topic(topic_name)
subscription = topic.subscription(subscription_name)

results = subscription.pull(return_immediately=True)

However a non-existent topic name can be supplied for topic_name and messages can still be received from the results.

The following code also works without having to specify a topic:

pubsub_client = pubsub.Client()
subscription = pubsub.subscription.Subscription(subscription_name, client=pubsub_client)

The gcloud.pubsub.topic.Topic.subscription documentation stating "Creates a subscription bound to the current topic" is misleading because it seems it binds to all topics.

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions