mookid8000/Rebus — pull request #180 by driis (2013-07-15 14:16:47+00:00)
Title: Improve error handling for Defer when running in an unsupported mode

This pull request is sparked by a bug I had when using Rebus, which took some time to hunt down, this should hopefully make it easier for others to spot their errors in the future:

I had inadverdently configured Rebus to use OneWayMode, and then tried to use bus.Defer() (silly me :-) )

It seemed to work without errors, but I never got a timeout. After investigation, it turned out that Rebus allows the Defer message to be delivered to the TimeoutService, although there is no way for the TimeoutService to deliver it back, because of OneWayMode. Also, the TimeoutService did not validate the input message, but failed deep in the bowels of the SQL persistence stuff, providing an error message that did not hint very much at the actual problem.

This pull request fixes this by allowing Rebus to fail fast, if it can determine that the call to Defer will not work in this scenario. It also adds an assertion to TimeoutRequestHandler, in case it receives bad messages from another source.