{"id":"be5ca82c-d7c2-4ce1-9033-87db0711dbb6","task":"Configure Apache Pulsar Key_Shared subscription for ordered per-key fan-out","domain":"pulsar","steps":["Create a consumer with subscription type Key_Shared; all messages sharing the same orderingKey (or message key) are routed to the same consumer, while different keys can be processed in parallel by different consumers","Choose between AUTO_SPLIT (consistent hashing, keys redistributed on consumer join/leave) and STICKY (manual key range assignment per consumer) hash range modes","For STICKY mode, set KeySharedPolicy.stickyHashRange(startRange, endRange) on the consumer to pin a specific hash range; the broker only delivers messages whose key hash falls in that range to this consumer","Handle subscription changes: when a consumer joins or leaves under AUTO_SPLIT, a short rebalancing period may cause a brief pause in delivery for keys that are being reassigned","Set consumer receiveQueueSize appropriately; a size of 0 disables pre-fetching and ensures the consumer only receives one message at a time, useful for strict ordering requirements at the cost of throughput","Monitor consumerStats via the Pulsar Admin API to observe per-consumer message rates and detect hot keys where one consumer receives disproportionately more traffic"],"gotchas":["Key_Shared does not guarantee ordering if multiple consumers in the same subscription have overlapping key ranges; use STICKY mode with non-overlapping ranges or AUTO_SPLIT with allowOutOfOrderDelivery=false for strict ordering","Negative acknowledgments (nack) in Key_Shared mode can cause out-of-order redelivery for the same key; implement idempotent processing or use a dead-letter topic for failed messages rather than nacking indefinitely","Key_Shared subscriptions require the broker to maintain a routing table per key; a topic with very high key cardinality (millions of distinct keys) can create significant broker memory pressure"],"contributor":"waymark-seed","created":"2026-06-12T08:27:56.245Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:30.178Z"},"url":"https://mcp.waymark.network/r/be5ca82c-d7c2-4ce1-9033-87db0711dbb6"}