I am asked to develop a layer that will act as a shared bus without any direct links to NServiceBus. Which is still thanks to the support of unobtrusive messages are not too complicated. Except now, I was asked to provide our own definition for IHandleMessages and find a way to map it during connection. So I think something like this:
public class MessageHandlerAdapter<T> : IHandleMessages<T> { IUnityContainer container; public MessageHandlerAdapter(IUnityContainer container) { this.container = container; } #region IMessageHandler<T> Members public void Handle(T message) { var handler = container.Resolve<IHandle<T>>(); handler.Handle(message); } #endregion }
Where IHandle will be our own definition (which, by the way, is exactly the same as IHandleMessages). I would expect to flip AppDomain and find all the classes that implemented IHandle and register them in the container, and then register a MessageHandlerAdapter with the same type T.
My problem is that I have not used NServiceBus for almost two years, and I do not remember where you can connect to similar functions in the NSB pipeline.
Mark j miller
source share