I'm trying to understand a little bit more about how PubSub ordering messages works with a very basic toy example. Basically, by using the python examples from the googleapis repo I'm able to publish ordered messages to a topic, and then read them through a subscription with order enabled.
What confuses me is that, if I publish the following set of messages
[
("message1", "key1"),
("message2", "key1"),
("message3", "key1"),
("message1", "key2"),
("message2", "key2"),
]
When I try to read them through either Pull or StreamingPull, PubSub behaves more of like a queue, and I'm only able to retrieve the init messages
[
("message1", "key1"),
("message1", "key2"),
]
Only after I ACK those messages, I can move forward, but then I only get again the message3
and message2
. Does this mean that for a Key X, message M+1 won't be available in the subscriptions until message M is acknowledged?
Is this queue-behaviour expected or am I missing something really obvious?
Thank you!
The only guarantee around delivery is that for the same ordering key, a subsequent message will not be delivered unless the previous message has been delivered. For both pull and streaming pull, the messages may come before an ack or they may only come after an ack, but there are not strong guarantees either way.