In Pulsar's Key_Shared subscription, the message key (partition key) or ordering key is used to determine which consumer receives a message. If an ordering key is set, it takes precedence for routing; otherwise, the partition key is used. This means messages with the same ordering key will always be delivered to the same consumer, preserving order for that key. If you use device_id as the ordering key, all messages with the same device_id go to the same consumer, regardless of org_id. If you use org_id as the ordering key, all messages with the same org_id go to the same consumer, regardless of device_id. Overlap occurs if the ordering key does not uniquely identify the grouping you expect.
According to
Pulsar documentation and
TypedMessageBuilder.java, ordering key is used for dispatch in Key_Shared mode, and partition key is only used if ordering key is not specified. Would you like more detail on how the routing logic works internally?
Sources:
-
Pulsar documentation: Key_Shared
-
TypedMessageBuilder.java 👍 0 button 👎 0 button 💡
Hint: Mention @runllm in the thread for followups.