Skip to content

Session Identifiers and FIFO Queues


This functionality was introduced in Wolverine 1.6.0.


Even if Wolverine isn't controlling the creation of the queues or subscriptions, you still need to tell Wolverine when sessions are required on any listening endpoint so that it can opt into session compliant listeners

You can now take advantage of sessions and first-in, first out queues in Azure Service Bus with Wolverine. To tell Wolverine that an Azure Service Bus queue or subscription should require sessions, you have this syntax shown in an internal test:

_host = await Host.CreateDefaultBuilder()
    .UseWolverine(opts =>



            // Require session identifiers with this queue

            // This controls the Wolverine handling to force it to process
            // messages sequentially



            // Require sessions on this subscription


snippet source | anchor

To publish messages to Azure Service Bus with a session id, you will need to of course supply the session id:

// bus is an IMessageBus
await bus.SendAsync(new AsbMessage3("Red"), new DeliveryOptions { GroupId = "2" });
await bus.SendAsync(new AsbMessage3("Green"), new DeliveryOptions { GroupId = "2" });
await bus.SendAsync(new AsbMessage3("Refactor"), new DeliveryOptions { GroupId = "2" });

snippet source | anchor


Wolverine is using the "group-id" nomenclature from the AMPQ standard, but for Azure Service Bus, this is directly mapped to the SessionId property on the Azure Service Bus client internally.

You can also send messages with session identifiers through cascading messages as shown in a fake message handler below:

public static IEnumerable<object> Handle(IncomingMessage message)
    yield return new Message1().WithGroupId("one");
    yield return new Message2().WithGroupId("one");

    yield return new Message3().ScheduleToGroup("one", 5.Minutes());

    // Long hand
    yield return new Message4().WithDeliveryOptions(new DeliveryOptions
        GroupId = "one"

snippet source | anchor

Released under the MIT License.