asp .net mvc程序发布到IIS
consumer.Received 去监听处理的时候,使用的BasicAck 手动确认,发现处理了消息,但是手动确认并未成功,该消息还在队列中
using (IConnection connection = factory.CreateConnection())
{
using (var _recvChannel = connection.CreateModel())
{
_recvChannel.QueueDeclare(queue, true, false, false, null);
var consumer = new EventingBasicConsumer(_recvChannel);
consumer.Received += (sender, ea) =>
{
var body = Encoding.UTF8.GetString(ea.Body.ToArray());
var Head = ea.BasicProperties.Headers;
if (true)
{
_recvChannel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false); //这里未生效
}
else
{
_recvChannel.BasicNack(deliveryTag: ea.DeliveryTag, multiple: false, requeue: true);
}
};
_recvChannel.BasicConsume(queue: queue, autoAck: false, consumer: consumer);
Console.ReadLine();
}
}