Azure Service Bus MQ

Enable in an existing Web App

Use the servicebus mixin to register an MQ Server for Azure Service Bus with an existing .NET App:

x mix servicebus

Worker Service Template

To start using Azure Service Bus in stand-alone MQ Servers (i.e. without HTTP access) is to run the MQ Server in an ASP.NET Core Worker Service by starting from a pre-configured project template:

Manual Configuration

Support for registering Azure Service Bus as an MQ Server in ServiceStack is available in ServiceStack.Azure NuGet package:

<PackageReference Include="ServiceStack.Azure" Version="8.*" />

Once installed ServiceBus can be configured the same way as any other MQ Servers, by first registering the ServiceBus IMessageService provider followed by registering all ServiceStack Services you want to be able to invoke via MQ’s:

[assembly: HostingStartup(typeof(MyApp.ConfigureMq))]

namespace MyApp;

public class ConfigureMq : IHostingStartup
{
    public void Configure(IWebHostBuilder builder) => builder
        .ConfigureServices((context, services) => {
            services.AddSingleton<IMessageService>(c => 
                new ServiceBusMqServer(context.Configuration.GetConnectionString("ServiceBus")));
        })
        .ConfigureAppHost(afterAppHostInit: appHost => {
            var mqServer = appHost.Resolve<IMessageService>().Start();
            // Register MQ endpoints for APIs
            mqServer.RegisterHandler<MyRequest>(ExecuteMessage);
            mqServer.Start();
        });
}