Prevent rmq consumer wedging by aborting on error.
Prevent rmq consumer wedging by aborting on error.

We have seen cases where the consumer becomes wedged.  This is caused by
exceptions being raised from the processer meaning that the messages
never get acked.  Because we're using a prefetch of 1, rabbitmq will not
send any more messages until the previous one has been acked, resulting
in a deadlock.

By rescuing these exceptions and exiting, the rabbitmq connection is
torn down etc, and rabbitmq will then requeue the unacked messages.  We
can then rely on upstart/puppet to restart the worker.

This error handling is intended as a final rescue for edge cases.  The
inner processor should handle most exceptions in a more nuanced manner.

See https://github.com/alphagov/email-alert-service/pull/31 for more
background on the issue.

alphagov/content-register,alphagov/content-register,alphagov/content-register