简体   繁体   English

使用 MassTransit 创建具有规则的 Azure 服务总线

[英]Creating Azure Service Bus with Rule with MassTransit

I'm using masstransit to consume messages from an azure service bus.我正在使用 masstransit 来使用来自 azure 服务总线的消息。 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?我发现了一些关于这个主题的帖子,比如这个: 设置消费者时是否有办法定义 Azure 服务总线规则/过滤器?

but without many success...但没有多少成功......

My subscription is created properly when configuring my consumers like this, but it has the $Default 1=1 filter.像这样配置我的消费者时,我的订阅是正确创建的,但它有 $Default 1=1 过滤器。

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?我错过了什么吗?

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'")
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM