In most cases, if not all NSB examples for ASP.NET (or MVC) have a web application sending a message using Bus.Send and possibly registering for a simple callback, which is essentially how I use it in your application.
What interests me is if it is possible and / or it makes sense to process messages in one ASP.NET application.
The main reason I ask is caching. The process might look something like this:
- The user initiates the request from the web application.
- The web application sends a message to the stand-alone application server and registers the change in the local database.
- In future page requests from the same user, the web application finds out about this change and lists it in a pending state.
- A lot of things happen in focus, and ultimately requests are accepted or rejected. The event is published with reference to the original request.
- At this point, the web application should start displaying the latest information.
Now, in a real web application, Iβm pretty sure that this pending request will be cached, possibly for a long period of time, because otherwise the application should query the database for pending changes every time the user requests current information.
Thus, when the request finally completes in the background, which may take a minute or a day, the web application needs, at a minimum, to invalidate this entry in the cache and perform another search in the database.
Now I understand that this can be controlled using SqlDependency objects, etc., but suppose they are unavailable - maybe this is not a SQL Server server, or maybe the request for current information falls into the service network, whatever. The question is, how does a web application know about a status change?
If you can handle NServiceBus messages in an ASP.NET application, what is the context of the handler? In other words, the IoC container will have to inject a bunch of dependencies, but how much are they? Is this all done in the context of an HTTP request? Or should everything be static / singleton for the message handler?
Is there a better / recommended approach to this problem?