0

When using publisher confirms, is it possible to recover the message that was nacked? I've been looking through the event arguments for Channel_BasicNacks and haven't found an object or property that corresponds to it.

I.e.:

_factory = new ConnectionFactory
{
        HostName = Settings.HostName, UserName = Settings.UserName, Password = Settings.Password,
        AutomaticRecoveryEnabled = true
};

_connection = _factory.CreateConnection();
Channel = _connection.CreateModel();

Channel.BasicAcks += Channel_BasicAcks;
Channel.BasicNacks += Channel_BasicNacks;
Channel.ConfirmSelect();

Channel.QueueDeclare(Settings.QueueName, true, false, false, null);
}

private void Channel_BasicNacks(object sender, RabbitMQ.Client.Events.BasicNackEventArgs e)
{
    IModel model = (IModel)sender;
    throw new NotImplementedException();
}
svick
  • 236,525
  • 50
  • 385
  • 514
Hoppe
  • 6,508
  • 17
  • 60
  • 114

1 Answers1

1

You may try to resend basic.nack'ed message again until it will be confirmed by basic.ack.

From Confirms (aka Publisher Acknowledgements) (Negative Acknowledgment section):

basic.nack will only be delivered if an internal error occurs in the Erlang process responsible for a queue.

basic.nack is not a common server method (I've never seen it), but it should be possible to triggered it via rabbitmqctl eval by breaking some internals.

pinepain
  • 12,453
  • 3
  • 60
  • 65
  • The question is can the message be recovered by the event that is raised on a nack – Hoppe Mar 08 '16 at 21:59
  • What do you mean then by 'recovered'? – pinepain Mar 08 '16 at 22:00
  • Can I get the contents of the message so that i can submit the message again. I.e. if "test1234" was submitted.... Get test1234 – Hoppe Mar 08 '16 at 22:02
  • Ah. No. Only `basic.reject` holds message and it props. `basic.ack` and `basick.nack` holds only `delivery-tag` and `multiple` flag. `requeue` flag from `basic.nack` is also unused when this method comes from server. – pinepain Mar 08 '16 at 22:05