Question

I was wondering if it's safe to host an NServiceBus endpoint that serves as an event publisher inside IIS?

To clarify, we use an application hosted in IIS as our CRM system (Microsoft Dynamics CRM), and I want to use NServiceBus to publish an event when a contact's information is updated.
MS CRM allows the use of custom plugins to react on a contact update, and I intend to create a plugin that publishes a 'ContactUpdated' event through NServiceBus for that situation. Hence, this will effectively mean that my NServiceBus event publishing endpoint is hosted in IIS.

Now, I know that a self-hosted NServiceBus endpoint will create its own worker thread to monitor incoming messages (in this case subscription messages) from the queue. Because IIS is free to unload a worker process if there are no more incoming web requests, it's usually not a good idea to use IIS to host long-running processes in. However, I'd say that the NServiceBus queue monitoring thread does not qualify as a long-running process because it doesn't do any processing and can be stopped at any time: new subscription requests will then simply be queued until the web application is restarted again.

I'm just wondering if the way IIS cleans up this NServiceBus thread is safe, from an NServiceBus perspective?

(Incidentally, I also found this article, but I have to admit that only the Scaling out argument resonates with me, and that is not relevant in our situation.)

Was it helpful?

Solution

Yes, it is safe to host an NServiceBus publishing endpoint in IIS.

As you said, if IIS were to unload your worker process then any pending subscription requests would be waiting in the queue. This is reasonable - as long as you don't make any assumptions about the order in which a subscription request would be handled and a new event published.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top