Skip to content

Extract a shared DatabaseListener base for the DB interop poll loop#3206

Merged
jeremydmiller merged 1 commit into
mainfrom
feat/db-poller-base
Jun 23, 2026
Merged

Extract a shared DatabaseListener base for the DB interop poll loop#3206
jeremydmiller merged 1 commit into
mainfrom
feat/db-poller-base

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

What

Extracts the common polling-listener loop shared by the three database interop transports into a single DatabaseListener base class in Wolverine.RDBMS.

Why

The NServiceBus (SQL Server, PostgreSQL) and MassTransit (PostgreSQL) interop listeners had independently duplicated the same loop: a cancellable background task that pops a batch, forwards it to the receiver, and backs off on idle/error, plus the boilerplate Address / Pipeline / StartAsync / StopAsync / DisposeAsync.

DatabaseListener now owns all of that. Each transport listener supplies only what's actually dialect-specific:

  • TryPopAsync(max, token) — the batch pop (NSB destructive DELETE … OUTPUT / … RETURNING; MassTransit fetch_messages lease).
  • CompleteAsync / DeferAsync — ack/nack (NSB: no-op / requeue via the sender; MassTransit: delete_message / unlock_message).
  • MaximumMessagesToReceive.

Net: ~80 lines of duplicated loop/lifecycle removed across the three listeners, one place to reason about the poll cadence and failure backoff.

Validation

All three database interop suites pass against the real foreign hosts:

  • NServiceBus + SQL Server — 4/4
  • NServiceBus + PostgreSQL — 4/4
  • MassTransit + PostgreSQL — 2/2

dotnet build wolverine.slnx -c Release clean (0 warnings, 0 errors).

🤖 Generated with Claude Code

…l loop

Pull the common polling-listener loop (cancellable background task, batch pop ->
ReceivedAsync, idle/error backoff, Start/Stop/Dispose, Address/Pipeline) out of
the three database interop listeners into a shared DatabaseListener base in
Wolverine.RDBMS. Each listener now supplies only its dialect-specific batch pop
(TryPopAsync) and ack/nack (CompleteAsync/DeferAsync) — NServiceBus SqlServer &
Postgres (destructive pop / requeue) and MassTransit Postgres (fetch_messages
lease / delete_message / unlock_message).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 9b10ee9 into main Jun 23, 2026
26 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.

1 participant