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();
}
}