Search code examples
c#azureazureservicebus

How to accomplish FIFO with Azure service bus topics


Have been looking for a Message bus with publish/subscribe functionality. Found that AWS SQS does not support FIFO, so had to give up on it. Working with Azure Service bus, found that queues do support FIFO, but it seems like Topics do not support FIFO. And topics are what we need, with their pub-to-many-sub model :(

Is it just a setting I am missing? I tried sending 100 messages from my C# client, and the subscribers got the messages in the wrong order. Any tips would be appreciated. Thanks!


Solution

  • You should be able to achieve this by setting property SupportOrdering to true

        // Configure Topic Settings
        TopicDescription td = new TopicDescription("TestTopic");
        td.SupportOrdering = true;
    
        // Create a new Topic with custom settings
        string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
    
        var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
        namespaceManager.CreateTopic(td);