Masstransit用户表现

时间:2016-03-30 08:03:43

标签: c# rabbitmq masstransit

我将Masstransit (version 3.2.4)RabbitMq (version 3.6.0)一起使用。

我的发布者:

var bus = Bus.Factory.CreateUsingRabbitMq(x => {
        x.Host(new Uri("rabbitmq://localhost/"), h => { });
    });

    var busHandle = bus.Start();

    for (int i = 0; i < int.MaxValue; i++)
    {
        bus.Publish(new Message() { Text = i.ToString() });
    }

    busHandle.Stop();
    Console.ReadKey();

我的订阅者:

var bus = Bus.Factory.CreateUsingRabbitMq(x =>
    {
        var host = x.Host(new Uri("rabbitmq://localhost/"), h => { });

        x.ReceiveEndpoint(host, "TestSubscriber", e =>
          e.Handler<Message>(a => 
          {
              Console.WriteLine(a.Message.Text);
              return Task.FromResult(0);
          }));
    });

    var busHandle = bus.Start();
    Console.ReadKey();
    busHandle.Stop();

当我运行Publisher / Subscriber时,我会查看统计信息。 发布每秒约为7406封邮件,订阅每秒约为2531封邮件。我不明白为什么订阅者的速度比出版商的速度低三倍。这是正常的,我怎样才能提高用户的速度?

enter image description here

0 个答案:

没有答案