zarusz/SlimMessageBus

[Host.AzureServiceBus] Supporting Subscription Sql Filter

baoduy opened this issue · 5 comments

I found this library is perfect for those developers who are working on Messaging applications.

As you know, Azure Service Bus allows defining SqlFilter for every subscription and I'm looking forward to the library soon supporting defining SQL filter when adding Consumer.

Here is a sample code snip when registering the consumer.

 mbb.Produce<BusMessage>(x => x.DefaultTopic("topic-1").
             .WithModifier((message, busMessage) =>{
                        busMessage.ApplicationProperties.Add(nameof(message.Name), message.Name);
             })
        .Consume<BusMessage>(c=>c.Topic("topic-1")
            .SubscriptionName("sub-1")
            .PrefetchCount(10)
            .Instances(1)
            .WithConsumer<BusMessageHandler>()
            .WithSqlFilter("Name=HelloWorld")
 )

Thanks
Steven

Hello @baoduy ,

Glad to hear you like SMB.

Regarding filters under a subscription, I think we could extend the recent feature of the topology creation and include filter creation:
https://github.com/zarusz/SlimMessageBus/blob/master/docs/provider_azure_servicebus.md#topology-provisioning

Let me add this in the next days and make it available as an RC release for you to try.

@baoduy a RC release is available in NuGet for you to try:
https://www.nuget.org/packages/SlimMessageBus.Host.AzureServiceBus/1.19.1-rc1

Here is an example:

  .SubscriptionSqlFilter("1=1") // ASB subscription SQL filters can also be created - see topology creation section

You can set your own rule name, add action if needed or add more filters.
This only works when the named rule does not exist.

Here are the updated docs:
https://github.com/zarusz/SlimMessageBus/blob/feature/asb_filter_creation/docs/provider_azure_servicebus.md#topology-provisioning

Hi @zarusz I have checked and it works well. Thank you so much for your quick response.

Glad to hear that. If you have more suggestions please open another issue. PRs are also welcome!

Sure Sure. We are planning to migrate some of our applications to your Library and will share if there are any defects or suggestions.