仅在任务完成时出列项目
Dequeue item only if task is completed
我正在使用 easynetq 订阅队列。
var logger = new RabbitMQLogger();
string cfg = ConfigurationManager.AppSettings["rabbitConfig"];
var bus = RabbitHutch.CreateBus(cfg, x => x.Register<IEasyNetQLogger>(_ => logger));
bus.Subscribe<MyRequest>("", msg =>
{
Console.WriteLine("Processing: " + msg.Name);
// call DoTask()
// if it's true remove this item from a queue on a rabbitmq server
// if it's false do nothing
});
private bool DoTask()
{
/// .. do something
return true;
}
How can I dequeue only if return value from DoTask is true?
EasyNetQ 在消费者处理程序 method/subscription 处理程序完成后确认消息。如果处理程序抛出异常(如果您让错误冒泡),EasyNetQ 的默认错误处理过程将处理它。消息和异常将被包装在错误消息中并放置在错误队列中,然后向代理发送 ACK。
您可以在修复错误情况后稍后重播消息。
可在此处找到更多信息:https://github.com/EasyNetQ/EasyNetQ/wiki/Error-Conditions(页面底部)
我正在使用 easynetq 订阅队列。
var logger = new RabbitMQLogger();
string cfg = ConfigurationManager.AppSettings["rabbitConfig"];
var bus = RabbitHutch.CreateBus(cfg, x => x.Register<IEasyNetQLogger>(_ => logger));
bus.Subscribe<MyRequest>("", msg =>
{
Console.WriteLine("Processing: " + msg.Name);
// call DoTask()
// if it's true remove this item from a queue on a rabbitmq server
// if it's false do nothing
});
private bool DoTask()
{
/// .. do something
return true;
}
How can I dequeue only if return value from DoTask is true?
EasyNetQ 在消费者处理程序 method/subscription 处理程序完成后确认消息。如果处理程序抛出异常(如果您让错误冒泡),EasyNetQ 的默认错误处理过程将处理它。消息和异常将被包装在错误消息中并放置在错误队列中,然后向代理发送 ACK。
您可以在修复错误情况后稍后重播消息。
可在此处找到更多信息:https://github.com/EasyNetQ/EasyNetQ/wiki/Error-Conditions(页面底部)