Skip to content

Publishing

You can configure explicit subscription rules to Azure Service Bus queues with this usage:

cs
var builder = Host.CreateApplicationBuilder();
builder.UseWolverine(opts =>
{
    // One way or another, you're probably pulling the Azure Service Bus
    // connection string out of configuration
    var azureServiceBusConnectionString = builder
        .Configuration
        .GetConnectionString("azure-service-bus");

    // Connect to the broker in the simplest possible way
    opts.UseAzureServiceBus(azureServiceBusConnectionString).AutoProvision();

    // Explicitly configure sending messages to a specific queue
    opts.PublishAllMessages().ToAzureServiceBusQueue("outgoing")

        // All the normal Wolverine options you'd expect
        .BufferedInMemory();
});

using var host = builder.Build();
await host.StartAsync();

snippet source | anchor

Conventional Subscriber Configuration

In the case of publishing to a large number of queues, it may be beneficial to apply configuration to all the Azure Service Bus subscribers like this:

cs
var builder = Host.CreateApplicationBuilder();
builder.UseWolverine(opts =>
{
    // One way or another, you're probably pulling the Azure Service Bus
    // connection string out of configuration
    var azureServiceBusConnectionString = builder
        .Configuration
        .GetConnectionString("azure-service-bus");

    // Connect to the broker in the simplest possible way
    opts.UseAzureServiceBus(azureServiceBusConnectionString).AutoProvision()
        // Apply default configuration to all Azure Service Bus subscribers
        // This can be overridden explicitly by any configuration for specific
        // sending/subscribing endpoints
        .ConfigureSenders(sender => sender.UseDurableOutbox());
});

using var host = builder.Build();
await host.StartAsync();

snippet source | anchor

Note that any of these settings would be overridden by specific configuration to a specific endpoint.

Released under the MIT License.