Skip to content

Named-connection overloads for every transport (Aspire parity, GH-5126) - #5159

Merged
jeremydmiller merged 5 commits into
mainfrom
gh-5126-transport-named-connections
Oct 23, 2026
Merged

jeremydmiller merged 5 commits into
mainfrom
gh-5126-transport-named-connections

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Closes #5126

Every Wolverine transport can now be configured by connection-string name, the way Aspire passes resources to a project (builder.AddProject(...).WithReference(resource) puts the value at ConnectionStrings:<name>). Every broker that supports named brokers gets a matching named-broker form. This is additive only: new overloads, and no change to how existing ones behave.

Naming

The issue spells the API as UseX(string connectionStringName). What shipped follows the existing UseRabbitMqUsingNamedConnection / UseKafkaUsingNamedConnection convention, Use<X>UsingNamedConnection(name, ...), plus AddNamed<X>BrokerUsingNamedConnection(broker, name, ...). A bare UseX(string) would collide with the existing UseX(string connectionString) overloads.

Core: one hook for every transport

options.ApplyNamedConnectionString(kind, name, aspireMethod, value => ...) in NamedConnectionStringExtensions:

Per transport

Transport Named-connection value (what Aspire supplies) Container-client overload
Azure Service Bus The emulator's full connection string, or a namespace endpoint (https://ns.servicebus.windows.net:443/) secured with a TokenCredential (default DefaultAzureCredential). EntityPath is dropped. Not feasible. Aspire registers only ServiceBusClient, the transport also needs an admin client built from the same credentials, and it disposes its client.
Amazon SQS / SNS The emulator service URL (http://localhost:4566) from LocalStack's AddLocalStack or the CommunityToolkit's AddFlociAws. Placeholder credentials are used unless set explicitly. Aspire.Hosting.AWS supplies no connection string, so real AWS uses the plain overloads or: Added: UseAmazonSqsTransportWithClientFromContainer / UseAmazonSnsTransportWithClientsFromContainer (+ named-broker forms) take the IAmazonSQS / IAmazonSimpleNotificationService registered by AddAWSService<T>(). Wolverine does not dispose container-owned clients.
NATS nats://[user:pass@]host:port (AddNats). Optional configure for auth/TLS/JetStream. Not added. NatsTransport owns its connection: it disposes it, recreates closed connections on retry, and applies its own options. Possible follow-up.
Redis A StackExchange.Redis configuration string (AddRedis) Already covered by UseRedisTransport(Func<IServiceProvider, IConnectionMultiplexer>)
Pulsar pulsar://, pulsar+ssl:// or host:port. Neither official Aspire nor the CommunityToolkit has a Pulsar integration, so the error names no Aspire method. No client integration exists
MQTT 3 / 5 (shared source) mqtt://host:port from the CommunityToolkit's AddMosquitto, plus mqtts://, ws(s)://, host:port and user:pass@ credentials No client integration exists
GCP Pub/Sub The emulator endpoint from the CommunityToolkit's AddFlociGcp (http://host:port). The project id remains an explicit argument, because endpoint URIs include it at configuration time. Emulator only; production uses UsePubsub. No client integration exists

Each transport's existing configure lambdas still apply immediately. I checked each transport, and none reads its connection settings before ConnectAsync/InitializeAsync (or the lazy client builders); details are in the commit messages.

Tests

Each transport test project has a new named_connection_5126 class. Each covers:

  • a missing name failing startup (default and named broker);
  • the value applied to the default and named broker for every supported format (with StubAllExternalTransports(), so no broker is needed);
  • an end-to-end send/receive against a local broker (ASB emulator, LocalStack, NATS and Redis testcontainers, Pulsar, an in-process MQTT broker, the Pub/Sub emulator).

The happy-path snippets are wrapped in #region sample_<transport>_using_named_connection / ..._named_broker_using_named_connection for the docs (#5156).

Local results:

  • CoreTests named_connection_string_binding_5126 + named_connection_string_validation_4527: 10/10
  • ASB 13/13, SQS 10/10, SNS 11/11, NATS 6/6 + 1/1 end-to-end, Redis 7/7, Pulsar 8/8, MQTT 16/16, MQTT5 16/16, Pub/Sub 8/8
  • Existing named-broker / per-tenant regression classes in SQS, SNS, NATS, Redis, Pulsar, MQTT and Pub/Sub: all green
  • dotnet build wolverine.slnx -c Release -f net9.0: 0 errors, and the only warnings are the existing MessagePack NU1902 advisory
  • Full CoreTests: 3808 total, 0 failed, 3800 succeeded, 8 skipped

Not in this PR

🤖 Generated with Claude Code

jeremydmiller and others added 5 commits October 23, 2026 06:24
…named connection string once the container is built and hands it to the transport

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ddNamedAzureServiceBusBrokerUsingNamedConnection

Accepts both shapes Aspire supplies: a full (emulator) connection string, or a namespace endpoint secured
through a TokenCredential (DefaultAzureCredential by default). EntityPath is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Pulsar: service URL (pulsar://, pulsar+ssl://, host:port)
- MQTT (shared source with Mqtt5): mqtt://, mqtts://, ws(s)://, host:port, user:pass@ credentials;
  Aspire method AddMosquitto (CommunityToolkit)
- GCP Pub/Sub: emulator endpoint only (CommunityToolkit AddFlociGcp); the project id stays explicit
  because endpoint URIs bake it in at configuration time

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…clients from the container

- Use/AddNamed...UsingNamedConnection: the value is the emulator service URL that LocalStack's AddLocalStack
  and the CommunityToolkit's AddFlociAws supply; placeholder credentials unless set explicitly
- ...WithClient(s)FromContainer: use IAmazonSQS / IAmazonSimpleNotificationService registered by
  AddAWSService<T>(); container-owned clients are not disposed by Wolverine
- Aspire.Hosting.AWS supplies no connection string, so real AWS stays on UseAmazonSqsTransport() or the
  from-container overloads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- NATS: nats://[user:pass@]host:port as Aspire's AddNats supplies; optional configure for auth/TLS/JetStream
- Redis: StackExchange.Redis configuration string as Aspire's AddRedis supplies; the IConnectionMultiplexer
  from Aspire's client integration is already covered by UseRedisTransport(Func<IServiceProvider, IConnectionMultiplexer>)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 02e7332 into main Oct 23, 2026
48 checks passed
This was referenced Oct 25, 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

1 participant