Hi, my workplace has been using pub/sub as messenger in our system.
We use user_id as the ordering key, and this week our system faced problem where messages from one specific user (which also is the ordering key), are always successfully published but subscriber/listener does not receive it at all. Other messages from different user does not get this problem.
This happens for all message of the one specific user/ordering_key for several days until we finally restarted our listener/subscriber, only then it finally works normally again.
I'm having assumption that there's something wrong with the subscriber ordering mechanism on the specific ordering key at one point, causing the newer message could not be received.
Does anyone ever face this kind of problem?
And how do I prevent this from happening in the future?
Hi @rayhanmustofa,
Welcome to Google Cloud Community!
Unacknowledged messages for a given ordering key can potentially delay delivery of messages for other ordering keys, especially during server restarts or traffic changes. The Re-deliveries of a message trigger redelivery of all subsequent messages for that key, even acknowledged ones.
To maintain order of messages, here are the workarounds that you can do:
Here are the best practices for ordered messaging in subscribing:
Note: Ordered delivery does come with some tradeoffs. In the ordered delivery case, failover requires coordination to ensure the messages are written to and read in the correct order.
I hope the above information is helpful.