Multiple retries

This is a wild unproven guess at a solution, based on 3 parts intuition and 2
parts dunnolol, however it seems to keep state linear in the number of retries
(as opposed to exponential which I had originally feared).

Before being merged:
- I need to prove to myself that the complete state space is covered and that
  all transitions make sense.
- Somebody else needs to explain to me what the hell this code actually does.
- More unit tests.
- Lots of manual testing against real brokers.

See #232