0

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?

Noone
  • 395
  • 1
  • 4
  • 17

1 Answers1

0

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'")
};
Noone
  • 395
  • 1
  • 4
  • 17