Skip to content

Pulsar: acknowledgment-strategy choice (individual / cumulative / batched) (#3180)#3202

Merged
jeremydmiller merged 1 commit into
mainfrom
feat/pulsar-ack-strategy-3180
Jun 22, 2026
Merged

Pulsar: acknowledgment-strategy choice (individual / cumulative / batched) (#3180)#3202
jeremydmiller merged 1 commit into
mainfrom
feat/pulsar-ack-strategy-3180

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Part of the Pulsar re-evaluation epic #3176. Fixes #3180. Builds on #3179.

The Pulsar analogue of the Kafka CommitMode overhaul (#3150). Adds a per-listener acknowledgment strategy.

Strategies

  • Individual (default) — ack each message as it completes (unchanged).
  • Cumulative — one ack confirms everything up to a point in the subscription. Exclusive/Failover only (a clear error is thrown at startup for Shared/Key_Shared).
  • Batched — individual acks flushed by count or interval; no ordering constraint, safe for any subscription type.

Cumulative ordering safety (the correctness-sensitive bit)

Wolverine's buffered listener completes messages out of order. A naive cumulative ack of a later message would confirm earlier, still-in-flight ones — silent message loss. PulsarAckHandler tracks in-flight ids and the completed set, and only ever advances the cumulative ack to the highest contiguous-completed message, so it never acks past in-flight work. This is proven deterministically by a unit test (complete 2 and 3 while 1 is in flight → no ack; complete 1 → single cumulative ack jumps to 3).

Changes

  • New PulsarAckStrategy enum + PulsarAckHandler (encapsulates all three modes, watermark logic, batch flush + shutdown flush).
  • PulsarListener tracks receipts and routes CompleteAsync through the handler (retry-consumer messages always ack individually); startup validation for cumulative-on-Shared.
  • PulsarListenerConfiguration.AcknowledgeIndividually() / AcknowledgeCumulative() / AcknowledgeInBatches(size, interval).

Tests

Deterministic handler unit tests (individual; batched-by-count; cumulative out-of-order watermark + in-order), startup rejection of cumulative-on-Shared, and an end-to-end batched delivery test. Docs updated.

🤖 Generated with Claude Code

…ched) (#3180)

Pulsar analogue of the Kafka CommitMode overhaul (#3150). Adds a per-listener ack strategy:

- Individual (default): ack each message as it completes (unchanged behavior).
- Cumulative: one ack confirms everything up to a point. Exclusive/Failover only — configuring it
  on a Shared/Key_Shared subscription throws a clear error at startup. Because the buffered listener
  completes out of order, the cumulative ack only ever advances to the highest CONTIGUOUS-completed
  message (PulsarAckHandler tracks in-flight ids and the completed set), so it never acks a
  still-in-flight message — no silent message loss.
- Batched: individual acks flushed by count or interval; no ordering constraint, safe for any
  subscription type.

New PulsarAckHandler encapsulates the three modes; PulsarListener tracks receipts and routes
CompleteAsync through it (retry-consumer messages always ack individually) and flushes batched acks
on shutdown. Config via AcknowledgeIndividually()/AcknowledgeCumulative()/AcknowledgeInBatches(...).

Tests: deterministic handler unit tests (individual, batched-by-count, cumulative out-of-order
watermark + in-order), startup rejection of cumulative-on-Shared, and an end-to-end batched
delivery test. Docs updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 42d4b3c into main Jun 22, 2026
25 checks passed
This was referenced Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pulsar: acknowledgment-strategy choice (cumulative + batched)

1 participant