mikehadlow/EasyNetQ — pull request #278 by reuzel (2014-09-18 19:43:22+00:00)
Title: Handle publish error (prevent unhandled task exception)

hi,

Thanks for the great library.

During failover testing we found an issue when publishing at high speeds. The rabbitMQ publish action may fail during a disconnect with SocketExceptions. When this occurs, our test program crashed with an unhandled task exception.

We found the source of this issue in the PublisherConfirms part of the code. When the publish action throws an exception, the created task is never returned to the caller. It is only present in the dictionary, where it will eventually be faulted with a timeout. As soon as the dictionary is cleared (when a connection to RabbitMQ is re-established), the orphaned faulted task will be garbage collected leading to the unhandled task exception.

This pull-request intends to fix that by faulting and removing the task when the publish action fails.

Regards,
Joost