GCP Pub/Sub Message Ordering optimization guide with Node.js Client Library 3.0
I'm working on a personal project and I'm trying to implement ordered message delivery using Google Cloud Pub/Sub with the Node.js client library (version 3.0.0)... I've enabled message ordering on my subscription, but it seems like messages are being processed out of order despite using the same ordering key. For instance, I send messages with ordering keys like so: ```javascript const {PubSub} = require('@google-cloud/pubsub'); const pubsub = new PubSub(); async function publishMessage(data, orderingKey) { const topicName = 'my-topic'; const dataBuffer = Buffer.from(data); const messageId = await pubsub.topic(topicName).publish(dataBuffer, {orderingKey}); console.log(`Message ${messageId} published.`); } // Publishing messages publishMessage('Message 1', 'key'); publishMessage('Message 2', 'key'); publishMessage('Message 3', 'key'); ``` In my subscriber, I'm logging the received messages to check their order: ```javascript const subscriptionName = 'my-subscription'; const subscription = pubsub.subscription(subscriptionName); const messageHandler = message => { console.log(`Received message: ${message.data.toString()}`); message.ack(); }; subscription.on('message', messageHandler); ``` When I run this, I sometimes see 'Message 3' being processed before 'Message 1', which is confusing me. I ensured that messages are sent in sequence with the same ordering key. I've checked the Pub/Sub documentation and confirmed that my topic and subscription are both set up correctly for ordered delivery. Is there something I'm missing or misconfigured? Could it be an scenario with the way the subscriber processes messages, or is there some limitation I need to be aware of? Any insights would be greatly appreciated! Is there a better approach?