Looking at the source code (.net client 3.1.3), it seems like the documentation is not quite accurate, as an IOException
gets thrown in case of Nacks, a rather strange choice if you ask me:
public void WaitForConfirmsOrDie(TimeSpan timeout)
{
bool timedOut;
bool onlyAcksReceived = WaitForConfirms(timeout, out timedOut);
if (!onlyAcksReceived) {
...
throw new IOException("Nacks Received");
}
Unfortunately that's just the source code, and the specification (in the api docs) differs. In any event, it looks like I could currently do this:
bool definitelyNotSend = e is IOException && "Nacks Received".Equals(e.Message);
There are, however, exceptions other than Nacks that may occur and imply the message has definitely not been sent, like when sending to an non-existing exchange. In that case, you'll get an AlreadyClosedException
with a ShutdownReason.ReplyCode
of 404.
Edit: My test in https://stackoverflow.com/a/18117000/709537 confirmed that the above IOException actually gets thrown.