'Creating Azure Service Bus with Rule with MassTransit

I'm using masstransit to consume messages from an azure service bus. It's going greate for nom but I need now to add filter rules to my subscription.

I found some posts on the subject, like this one: Is there a way to define a Azure Service Bus rule/filter when setting up a consumer?

but without many success...

My subscription is created properly when configuring my consumers like this, but it has the $Default 1=1 filter.

cfg.SubscriptionEndpoint<MyMessage>(mySubscription, cfg =>
{                            
    se.Consumer<MyConsumer>(x => x.UseConcurrentMessageLimit(1));
});

I would like to add a different filter, but when I do this, the creation of the subscription seems to fail silently

cfg.SubscriptionEndpoint<MyMessage>(mySubscription, cfg =>
{                            
    cfg.Rule = new CreateRuleOptions
    {
        Name = "Receiver filter",
        Filter = new SqlRuleFilter("receiver='all'")

    };

    se.Consumer<MyConsumer>(x => x.UseConcurrentMessageLimit(1));
});

I'm I missing something?



Solution 1:[1]

I found my mistake... Everything is fine except for one thing. The rule name does not support spaces.

cfg.Rule = new CreateRuleOptions
{
    Name = "ReceiverFilter", // instead of "Receiver filter"
    Filter = new SqlRuleFilter("receiver='all'")
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JCorriveau