0

I'm subscribing to a queue using 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?

user1765862
  • 13,635
  • 28
  • 115
  • 220

1 Answers1

1

EasyNetQ ACKs the message once the consumer handler method/subscription handler completes. If the handler throws an exception (if you let your error bubble up), EasyNetQ's default error handling process will handle it. The message and exception will be wrapped in an error message and placed on the error queue, then an ACK is sent to the broker.

You can then replay the message at a later date after you've fixed the error condition.

More information can be found here: https://github.com/EasyNetQ/EasyNetQ/wiki/Error-Conditions (bottom of the page)

Lovisa Johansson
  • 9,721
  • 1
  • 16
  • 20