question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Callback mechanism for listening to Pub/Sub messages

See original GitHub issue

I’d love for there to be a mechanism to set up perpetual pulling and acknowledging of Cloud Pub/Sub messages, the sort of thing that might enable code like this:

# Messages are acknowledged unless DoWork raises an exception
def DoWork(message):
    print "Message payload: %s" % message.payload

worker_thread = subscription.pull(callback=DoWork)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tseavercommented, May 12, 2016

FWIW, PR’s #1636 and #1637 offer competing strategies for doing “auto-acknowlegement” of message IDs.

0reactions
tseavercommented, Aug 25, 2016

And FTR we merged the implementation in #1636, making your example above look like:

while True:
    with subscription.auto_ack() as ack:
        for ack_id, message in list(ack.items()):
            try:
                do_something_with(message)
            except WhateverException:
                del ack[ack_id]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pull subscriptions | Cloud Pub/Sub Documentation
In a pull subscription, a subscriber client requests messages from the Pub/Sub server. The pull mode can use one of the two service...
Read more >
Google Cloud PubSub messages not processed by callback
However, some of the messages sent seem to be randomly dropped, and are not processed by the subscriber's callback method.
Read more >
How to use Google Pub/Sub to build an asynchronous ...
A callback function is added to the subscriber. The callback function will be called automatically when some message is published to the topic...
Read more >
Things I wish I knew about Google Cloud Pub/Sub: Part 2
First, a publisher sends a message to the topic. Once the Pub/Sub server receives the message, it adds fields to the message such...
Read more >
Pub/Sub | API | AmplifyJS - A Component Library for jQuery
callback : Function to invoke when the message is published. [ priority ]: Priority relative to other subscriptions for the same message. Lower...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found