0
votes

I am trying to create a Publish Subscribe facade that internally uses NServiceBus for the PubSub functionality. One of the issues I am having doing this with NServiceBus is that a lot of the configuration is done via interfaces. A Publisher will implement IWantToRunAtStartup, for instance. The endpoint for that publisher will implement IConfigureThisEndpoint and AsA_Publisher.

This is a very cool feature, is "fluent" and makes the code easy to read and understand.

But it makes it hard to create a facade. A base class which implements IWantToRunAtStartup, for instance, will require all super classes to reference NServiceBus.Host.

Having a requirement to reference NServiceBus, of course, totally breaks the idea of having the facade. What's the point of the facade at that point?

Does NServiceBus have a way of configuring types as endpoints, publishers, subscribers, and messages that does not use the Interface technique? And if so, could someone point me to that documentation (or, even better, a sample?)

1

1 Answers

1
votes

The interfaces IConfigureThisEndpoint, AsA_Publisher, and IWantToRunAtStartup are not necessary for setting up publish/subscribe.

If you aren't hosting your endpoint in NServiceBus.Host.exe, all you need to do is tell NServiceBus how it should store subscriptions - in memory, using msmq, a relational database, or in RavenDB. Just choose the appropriate method as a part of your Configure.With()... initialization code.

As of version 3.0, NServiceBus supports the definition of message types that don't have any dependency on NServiceBus - see http://docs.particular.net/nservicebus/messaging/unobtrusive-mode

In any case, the code in your subscribers that will be handling the events being published will need to implement the NServiceBus interface IHandleMessages.

Generally speaking, I'd say that NServiceBus is different enough in philosophy from other service buses that moving from one to the other will not be significantly easier with or without a facade.