【问题标题】:Masstransit MaxConcurrentCalls setting on Azure being ignoredAzure 上的 Masstransit MaxConcurrentCalls 设置被忽略
【发布时间】:2017-02-04 02:35:21
【问题描述】:

我在 Azure 上的 MassTransit 和在总线上配置 MaxConcurrentCalls 时遇到问题。我有一个进程需要一次执行 1 条消息,但我无法使用总线配置来实现这一点。 例如在总线配置期间,我设置了以下内容

busConfigurator.MaxConcurrentCalls = 1;
busConfigurator.PrefetchCount = 0;

注册消费者后,我立即向端点发送 3 条消息,立即创建 3 个消费者实例并开始处理。下面是来自 Log4Net 的日志片段。

我想知道有没有其他人遇到过这个问题以及他们如何解决它,或者知道我可能做错了什么。从下面的日志中可以看出,这些消息会立即开始执行,即使每条消息都需要大约 10-15 秒的时间来处理。

[2017-02-03 16:48:18,410]   [DEBUG] [13]    [svcbus.Consumers.SellerPageConsumer]   [Consume]   []  [Loading page https://....... ]     
[2017-02-03 16:48:18,410]   [DEBUG] [14]    [svcbus.Consumers.SellerPageConsumer]   [Consume]   []  [Loading page https://....... ]     
[2017-02-03 16:48:18,420]   [DEBUG] [23]    [svcbus.Consumers.SellerPageConsumer]   [Consume]   []  [Loading page https://....... ]     

【问题讨论】:

    标签: azure masstransit


    【解决方案1】:

    更新
    我查看了 Azure 配置属性。
    配置接收端点时,您可以在那里设置 MaxConcurrentCalls 和 PrefechCount。
    应该工作

    configurator.ReceiveEndpoint(host,"QueueName", re =>
    {
        re.MaxConcurrentCalls = 1;
        re.PrefetchCount = 1;
        //configure consumers & other stuff here ...
    });
    

    旧答案
    不是 azure 特定的,但在 RabbitMQ 上,我通过在配置器对象上调用 UseConcurrencyLimit 来设置最大并发消费者 例如

    bus = MassTransit.Bus.Factory.CreateUsingRabbitMq(configurator =>
    {
        configurator.UseConcurrencyLimit(options.MaxConcurrentConsumers);
        . . .
    }
    

    Azure 配置器上有类似的东西吗?

    【讨论】:

    • 抱歉,Azure 没有类似的东西。只是上面提到的一个设置,比如 busConfigurator.MaxConcurrentCalls = 1。
    • 是的,这行得通,我刚刚下载了 MT 代码并发现了相同的。我不确定这是否是设计使然。我会在 GitHub 上的项目中弹出一个问题,看看会发生什么。
    猜你喜欢
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-25
    • 2015-04-14
    相关资源
    最近更新 更多