Creating pubsub subscription with message ordering

  • date 31st May, 2021 |
  • by Prwatech |
  • 0 Comments

Enable message ordering for Pub/Sub subscriptions

 

Enabling message ordering for Google Cloud Pub/Sub subscriptions ensures that messages are delivered to subscribers in the order they were published to the topic. This feature is crucial for scenarios where message sequence is essential for correct processing or maintaining data integrity, such as processing financial transactions, maintaining stateful workflows, or ensuring consistency in event-driven systems.

To enable message ordering in Pub/Sub subscriptions, users need to set the attribute enableMessageOrdering to true when creating or updating the subscription. When message ordering is enabled, Pub/Sub guarantees that messages with the same ordering key are delivered to subscribers in the order they were published, preserving the message sequence.

It's important to note that enabling message ordering can impact system performance and throughput, as Pub/Sub may need to serialize message delivery to ensure order preservation. Therefore, users should carefully consider the trade-offs between message ordering and system scalability when designing their Pub/Sub subscriptions.

Additionally, users should ensure that their message processing logic can handle potential delays or latencies introduced by message ordering, especially in high-throughput or latency-sensitive applications.

Prerequisites

GCP account

Open Console.

Open  Menu > Pubsub > Subscriptions

Click on create  Subscription

Give the subscription ID.

Choose the pubsub topic.

the delivery type.

Choose the retention period for message. Choose the expiration period.

Give the Acknowledgement time

Tick Order messages with an ordering Key.

Click Create. The subscription with Ordering of message will be created.

Quick Support

image image