talkiq / gcloud-aio

(Asyncio OR Threadsafe) Google Cloud Client Library for Python
https://talkiq.github.io/gcloud-aio
275 stars 90 forks source link

Publishing message with a ordering key #728

Closed pedrorjbr closed 5 months ago

pedrorjbr commented 5 months ago

Is it possible to publish a message using ordering_key? this code is from pubsub library gcp.


    publisher_options = pubsub.types.PublisherOptions(
        enable_message_ordering=enable_message_ordering
    )
    self.publisher = pubsub.PublisherClient(publisher_options=publisher_options)

future = self.publisher.publish(
            topic=topic_path, data=data, ordering_key=ordering_key
        )
TheKevJames commented 5 months ago

Yes indeed, the PubsubMessage constructor takes an ordering_key as a parameter, setting it there when crafting the message should do the trick.