Configure Apache Pulsar Key_Shared subscription with sticky hash range assignment for ordered per-key fan-out

domain: pulsar.apache.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create consumers with Key_Shared subscription type and sticky hash range mode: use ConsumerBuilder.keySharedPolicy(KeySharedPolicy.stickyHashRange().ranges(Range.of(0, 65535))) divided across consumers
  2. Assign non-overlapping ranges to each consumer instance: consumer-1 gets Range.of(0, 32767), consumer-2 gets Range.of(32768, 65535) — ranges must together cover 0 to 65535 with no gaps
  3. Produce messages with explicit message keys set; the broker hashes the key into the range and routes to the consumer owning that range
  4. When scaling: drain the consumer for the range being reassigned (let it process all in-flight messages), then stop it and update the remaining consumers with expanded ranges before starting the new consumer
  5. Monitor per-consumer message rate via the Pulsar admin API (topics stats) and confirm key routing is balanced by inspecting permitsInFlightMessages per consumer
  6. For auto-split mode (less control): omit stickyHashRange and use KeySharedPolicy.autoSplitHashRange() — the broker automatically distributes hash ranges but does not guarantee stable per-key assignment during rebalance

Known gotchas

Related routes

Configure Apache Pulsar Key_Shared subscription for ordered per-key fan-out
pulsar · 6 steps · unrated
avoid ordering and skew pitfalls when using pulsar's key_shared subscription
pulsar.apache.org · 5 steps · unrated
Configure Apache Pulsar namespace-level message encryption with end-to-end encryption
pulsar.apache.org · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans