Using NServiceBus in a web application

Another question on the topic is Using NServiceBus with an Asp.Net MVC 2 stream . Udi replied that the following method can be used if we really want to do this.

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 works great 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 expect a callback. There will be only one queue of answers (if my understanding is correct).

Does NServiceBus know which thread to resume based on the received response from the queue?

, ( - , )

", , GetCustomersByRegionRequest CustomersByRegionResponse, ". - http://docs.particular.net/

+3
1

NSB , . , . , Request/Response . , , Request/Response . . , .

+1

Source: https://habr.com/ru/post/1771528/


All Articles