RabbitMQ的C#API基于事件信息消费 [英] RabbitMQ C# API Event based Message Consumption
本文介绍了RabbitMQ的C#API基于事件信息消费的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
while (true)
{
BasicDeliverEventArgs e = (BasicDeliverEventArgs)Consumer.Queue.Dequeue();
IBasicProperties properties = e.BasicProperties;
byte[] body = e.Body;
Console.WriteLine("Recieved Message : " + Encoding.UTF8.GetString(body));
ch.BasicAck(e.DeliveryTag, false);
}
这是我们做什么,当我们通过subscription..We使用While循环提取信息,因为我们希望消费者听Continously..what,如果我想使这甚至based..that是当新邮件到达队列当时只有消费者要消耗任何这样类似的事件message..or ..
This is what we do when we Retrieve Message by subscription..We use While Loop because we want Consumer to listen Continously..what if i want to make this even based..that is when a new message arrives in the queue at that time only Consumer should Consume the message..or on any such similar event..
推荐答案
使用 RabbitMQ.Client.Events.EventingBasicConsumer
的三项赛的消费者,而不是一个阻断一个。
use the RabbitMQ.Client.Events.EventingBasicConsumer
for a eventing consumer instead of a blocking one.
这篇关于RabbitMQ的C#API基于事件信息消费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文