If messages with the same partition key are being delivered to multiple consumers in a Key_Shared subscription, the most likely cause is that your consumers are not using the same subscription name. In Pulsar, each unique subscription name creates a separate subscription, so each will receive all messages independently, regardless of key. For Key_Shared to work as intended (messages with the same key go to the same consumer), all consumers must use the same subscription name and Key_Shared type. This is a common mistake and is confirmed in
this issue and
this issue.
Additionally, ensure that your producer is correctly setting the key (or orderingKey/partitionKey, depending on client language), and that batching is either disabled or set to key-based batching, as default batching can break Key_Shared guarantees (
Pulsar docs,
batching details).
Would you like more detail or troubleshooting steps?
Sources:
-
KeyShared Consumer Issue Example
-
KeyShared Subscription Type
-
Batching for KeyShared Subscriptions
-
KeyShared Consumer Example 👍 1 button 👎 0 button 💡
Hint: Mention
@RunLLM in the thread for followups.