Skip to content

[Documentation Issue] Pub/Sub default max_messages is unclear in 0.13.0 docs #1756

@joeholley

Description

@joeholley

Page Name: pubsub-usage
Release: 0.13.0

This section:

Fetch pending messages for a pull subscription:

>>> from gcloud import pubsub
>>> client = pubsub.Client()
>>> topic = client.topic('topic_name')
>>> subscription = topic.subscription('subscription_name')
>>> with topic.batch() as batch:
...     batch.publish('this is the first message_payload')
...     batch.publish('this is the second message_payload',
...                   attr1='value1', attr2='value2')
>>> received = subscription.pull()  # API request
>>> messages = [recv[1] for recv in received]
>>> [message.message_id for message in messages]
[<message_id1>, <message_id2>]
>>> [message.data for message in messages]
['this is the first message_payload', 'this is the second message_payload']
>>> [message.attributes for message in messages]
[{}, {'attr1': 'value1', 'attr2': 'value2'}]

Does not pull all pending messages in my very simple test code. It only pulls one pending message. I can get multiple by specifying 'max_messages' greater than 1 in the 'subscription.pull()' call.

Has something changed in the implementation since this doc was written?

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