I am attempting to set up RabbitMQ for a pair of Windows Services I am writing, to facilitate communication between them in a quick and reliable way. However, I'm running into a problem when trying to set up the main windows service engines, which need to establish connections to the RabbitMQ server to do their thing.
Basically, the ConnectionFactory object in RabbitMQ's .NET client is not abstract and implements no interfaces. I can't see an obvious way to inject this class using an IoC container like StructureMap. Even the code examples in the documentation show just blatantly newing it up, like so:
ConnectionFactory factory = new ConnectionFactory();
factory.Uri = "amqp://user:pass@hostName:port/vhost";
IConnection conn = factory.CreateConnection();
The solution that presents itself to me is to push up the entire factory into the service's main OnStart and OnStop functions, which are really difficult to test and not of huge interest anyway. However, that leaves me with a single IConnection for the service, so if that connection is broken in any way, the service has no way to recover and must simply exit. If the main engine had visibility to the factory, it could simply produce a new connection and continue. But unless I inject that, there is no way to test the main engine without connecting to an existing server!
Is there anything I am missing here? Any other option I'm not considering? How can I go about injecting this factory, and if I can't, how can I limit the damage?
EDIT: Also, as an afterthought, I'm perfectly happy to make a change to RabbitMQ's .NET client to implement an interface on this if someone has a good idea of how receptive the main dev team would be to a change like this. I'd be delighted to contribute, but the last thing I want to do is have my programs working on some custom version of RabbitMQ, thereby eliminating the main benefit of using a third party library in the first place.