with-agents

Pub/Sub Made Easy

Receiving messages using Pull - ep. 7

A ten-episode progression through topics, subscriptions, clients, endpoints, and replay

Ten 2019–2020 episodes follow a message from publication to independent subscription backlogs, delivery, acknowledgement, and replay. Examples compare push and pull consumers and connect them to serverless endpoints.

Google Cloud Tech 7 of 10
In this collection Browse 10 summaries 7 of 10

The fictional Cat-Out shop needs to process a surge of poster orders through an internal packaging service with no public HTTP endpoint. The episode uses that example to explain streaming pull, then shows how to keep a subscriber from accepting more messages than it can process.

Key points

  • Streaming pull is a client-initiated persistent connection: The client library opens a bidirectional connection and receives messages continuously. Unlike push, the subscriber does not need a public endpoint for Pub/Sub to call 01:04–03:12(opens in a new tab).
  • Messages can carry subscriber-facing attributes: The sample sends user, city, and product identifiers alongside the payload for downstream processing 02:07–03:12(opens in a new tab).
  • Limit how much work one subscriber holds: A busy client can hold unacknowledged messages while another client has spare capacity. Extending those messages' deadlines keeps them assigned to the busy client and consumes its resources. The sample limits a client to ten outstanding messages; a sustained backlog may also call for more subscriber instances 03:12–05:19(opens in a new tab).
  • Extend the deadline when processing needs more time: If a message is not acknowledged before its deadline, Pub/Sub can send it again. Extending that deadline reduces premature redelivery. Setting it to zero instead forces Pub/Sub to retry the message 05:19–06:23(opens in a new tab).
  • Synchronous pull lets the application request a bounded batch: The episode's notification service can receive no more than ten messages per HTTP request. It recommends synchronous pull for that precise cap, for polling, or for languages such as PHP that lacked the gRPC support streaming pull needed at the time 05:19–07:26(opens in a new tab).

Full video: https://www.youtube.com/watch?v=cCkwo6eEHIg(opens in a new tab)

Search

Search field guides and resources across the site.

    Keyboard shortcuts

    Press ? to open this guide (usually Shift + /). Close it before using other site shortcuts.

    Show keyboard shortcuts
    ?
    Search site
    Ctrl + K
    Close the current dialog or menu
    Esc

    Site shortcuts are ignored while typing. Browser and extension shortcuts may take priority.