RabbitMQ .NET客户端是否有任何异步支持?我希望能够异步连接和使用消息,但到目前为止还没有找到办法.
(对于消费消息,我可以使用EventingBasicConsumer,但这不是一个完整的解决方案.)
为了给出一些上下文,这是我现在如何使用RabbitMQ的一个例子(代码取自我的博客):
var factory = new ConnectionFactory() { HostName = "localhost" };
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
channel.QueueDeclare("testqueue", true, false, false, null);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += Consumer_Received;
channel.BasicConsume("testqueue", true, consumer);
Console.ReadLine();
}
}
Run Code Online (Sandbox Code Playgroud)