我将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
封邮件。我不明白为什么订阅者的速度比出版商的速度低三倍。这是正常的,我怎样才能提高用户的速度?