Hello,
Another question on "Using NServiceBus with Asp.Net MVC 2" (http://stackoverflow.com/questions/3668648/using-nservicebus-with-asp-net-mvc-2) thread. Udi has replied saying following method can be used if we really want to do it.
var sync = Bus.Send<SomeMessage>(/*data*/)
.Register((AsyncCallback)delegate(IAsyncResult ar)
{
var result = ar.AsyncState as CompletionResult;
// do something with result.Messages
},
null
);
sync.AsyncWaitHandle.WaitOne( /*timeout*/);
This will work perfectly in a windows application, because there is only one user.
I wonder how this will work in a web application; since there are multiple threads (for multiple user sessions) call Bus.Send and waiting for the callback. There will be only one reply queue (if my understanding is correct).
Does NServiceBus know which thread to resume based on the response message it received from queue?
If my understanding is correct, it's not recommended to use messaging for these kind of scenarios (send a request message from a web Application to a Service, which handle the message and reply with a response message)
"For example, if you want to perform queries like GetCustomersByRegionRequest and CustomersByRegionResponse, that should not be implemented using messaging." - http://www.nservicebus.com/Documentation.aspx