Skip to content

MassTransit PostgreSQL transport interop#3203

Merged
jeremydmiller merged 2 commits into
mainfrom
feat/db-interop-mt-postgresql
Jun 22, 2026
Merged

MassTransit PostgreSQL transport interop#3203
jeremydmiller merged 2 commits into
mainfrom
feat/db-interop-mt-postgresql

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

What

Adds a database-backed Wolverine transport that interoperates bidirectionally with a MassTransit application using the PostgreSQL SQL transport. Third permutation of the database-backed transport interop plan, after #3198 (NSB/SQL Server) and #3201 (NSB/PostgreSQL).

How — different from NServiceBus

MassTransit's SQL transport is not a documented "write the table" contract. It's a function-driven, two-table model — transport.message (the bare contract JSON in body + envelope fields as columns) and transport.message_delivery (per-queue lease/retry rows) — that MassTransit owns and migrates itself. So masstransit-postgresql (in Wolverine.Postgresql) interoperates by calling MassTransit's stored functions rather than reading/writing a Weasel-modeled table (no IDatabase):

  • Send: transport.send_message with the bare message body (jsonb) + the envelope columns and the urn:message:{Namespace}:{TypeName} message type, content type application/json. (Must supply priority and sent_time — the function defaults them to NULL but the underlying columns are NOT NULL.)
  • Receive (lease): transport.fetch_messages(queue, consumer_id, lock_id, lock_duration, count); ack via delete_message, nack via unlock_message, tracked per envelope by (message_delivery_id, lock_id).
  • Provision (opt-in): create_queue_v2 for the queues Wolverine listens to.
  • Resolves the urn back to a Wolverine message type across loaded assemblies (RegisterInteropMessageAssembly), reusing Wolverine's MassTransit db:// URI conventions (IMassTransitInteropEndpoint). Reply address falls back from response_address to source_address.

Tests

  • Both directions green against a real MassTransit 8.5.10 PostgreSQL host in the wolverine-interop repo (InteropTestsWithMassTransitAndPostgresql) — masstransit_sends_message_to_wolverine and wolverine_sends_message_to_masstransit_that_then_responds, stable across repeated runs.
  • dotnet build wolverine.slnx -c Release clean (0 warnings, 0 errors).

Docs

  • docs/guide/durability/postgresql.md — MassTransit interoperability section.
  • docs/tutorials/interop.md — MassTransit over database transports section.

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits June 22, 2026 17:35
Add a database-backed transport (masstransit-postgresql) that interoperates
bidirectionally with MassTransit's PostgreSQL SQL transport by calling its
stored functions. Unlike NServiceBus, MassTransit's SQL transport is a
function-driven two-table model (transport.message + transport.message_delivery)
that owns and migrates its own schema, so this transport calls functions rather
than reading/writing a Weasel-modeled table (no IDatabase).

- Send via transport.send_message (bare message body in jsonb + envelope columns,
  message_type urn:message:{ns}:{type}, content_type application/json); must
  supply priority and sent_time (the function defaults them to NULL but the
  message/message_delivery columns are NOT NULL).
- Lease receive via transport.fetch_messages (per-listener consumer_id + per-poll
  lock_id); ack via delete_message, nack via unlock_message, tracked per envelope.
- Resolve the urn back to a Wolverine message type across loaded assemblies
  (RegisterInteropMessageAssembly), falling back to the full Namespace.TypeName.
- Reply address falls back from response_address to source_address.
- AutoProvision (opt-in) calls create_queue_v2; reuses Wolverine's MassTransit
  db:// URI conventions (IMassTransitInteropEndpoint).

Both directions green vs a real MassTransit 8.5.10 PostgreSQL host (in
wolverine-interop).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rial)

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