azureservicebusazure-servicebus-queuesrebusazure-servicebus-topicsazure-servicebus-subscriptions

Code example for using Rebus with Azure Service Bus, Queue and Topic


I am new to Rebus, I am looking for code sample for using Rebus with Azure Service Bus, Queue and Topic.

I cannot see it from the link below: https://github.com/rebus-org/RebusSamples

Update

To start off: Sample of enqueuing and dequeuing messaging to Azure Service Bus for Queue, and Topic, configuration.

Ideally, cover more areas of Azure service bus, if possible.


Solution

  • if you want to use Azure Service Bus with Rebus, you can literally get going with something as simple as

    services.AddRebus(
        configure => configure
            .Transport(t => t.UseAzureServiceBus(connectionString, "my_queue"))
    );
    

    using Rebus.ServiceProvider with Microsoft's generic host, or

    Configure.With(activator)
        .Transport(t => t.UseAzureServiceBus(connectionString, "my_queue"))
        .Start();
    

    where activator is either Rebus' BuiltinHandlerActivator, or a container adapter for your favorite IoC container.

    You might want to check out the wiki page about the Azure Service Bus transport – it shows the basics of the configuration, and also explains some more stuff about e.g. long-running message handlers.