Extract a shared DatabaseListener base for the DB interop poll loop#3206
Merged
Conversation
…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>
This was referenced Jun 23, 2026
Closed
This was referenced Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extracts the common polling-listener loop shared by the three database interop transports into a single
DatabaseListenerbase class inWolverine.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.DatabaseListenernow owns all of that. Each transport listener supplies only what's actually dialect-specific:TryPopAsync(max, token)— the batch pop (NSB destructiveDELETE … OUTPUT/… RETURNING; MassTransitfetch_messageslease).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:
dotnet build wolverine.slnx -c Releaseclean (0 warnings, 0 errors).🤖 Generated with Claude Code