googleapis / python-pubsub

Apache License 2.0
385 stars 200 forks source link

Call "activate_ordering_keys" After Callback Instead of After Ack #1181

Open pof-declaneaston opened 3 months ago

pof-declaneaston commented 3 months ago

We are building an subscriber app where we want messages from the same user should be delivered to the same machine while previous messages from that user are being processed, while still being delivered in order.

PubSub gives us ordering and subscriber affinity, but the way message ordering is implemented in the client stops us from receiving messages until we ack, which we don't want to do until processing is done (for correctness and to keep subscriber affinity).

In the original message ordering PR there was a discussion about how the "activate_ordering_keys" function could be called after the callback instead of after acking the message. I would like to apply that change so that we can have messages delivered right away.

I would be happy to make a PR although I will probably have to talk to my manager about licensing. I drafted it out in this branch https://github.com/googleapis/python-pubsub/compare/main...pof-declaneaston:python-pubsub:feature/next_message_after_callback.

Please let me know if this is an acceptable change and if I am on the right track with my coding. Should I make this behaviour configurable for backwards compatibility?