Search code examples
wcfarchitecturenservicebusnservicebus5

NServiceBus and WCF, how do they get along?


Simplified... We are using NServiceBus for updating our storage.

In our sagas we first read data from our storage and updates the data and puts it back again to storage.The NServicebus instance is selfhosted in a windows service. Calls to storage are separated in its own assembly ('assembly1').

Now we will also need synchronous read from our storage through WCF. In some cases there will be the same reads that were needed when updating in sagas.

I have my opinion quite clear but maybe I am wrong and therefore I am asking this question...

Should we set up a separate WCF service that is using a copy of 'assembly1'? Or, should the WCF instance host nservicebus? Or, is there even a better way to do it?

It is in a way two endpoints, WCF for the synchronous calls and the windows service that hosts nservicebus (which already exists) right now.


Solution

  • I see no reason to separate into two distinct endpoints in your question or comments. It sounds like you are describing a single logical service, and my default position would be to host each logical service in a single process. This is usually the simplest approach, as it makes deployment and troubleshooting easier.

    Edit

    Not sure if this is helpful, but my current client runs NSB in an IIS-hosted WCF endpoint. So commands are handled via NSB messages, while queries are still exposed via WCF. To date we have had no problems hosting the two together in a single process.