I have a web service that needs to make a call to nservicebus in a synchronized manner. How can this be achieved ?
A:
Take a look at the AsyncPages sample. If you want it to be synchronous just block until the callback completes.
Hope this helps!
Andreas
2010-01-05 15:20:13
A:
There's also the option of exposing an NServiceBus endpoint as a web service and wcf service, and those can be invoked synchronously as you would expect.
Udi Dahan
2010-01-07 12:33:13
A:
The client is not an aspx page so I cannot use it like the async sample. I am using RIA services, so I am in no control of the synhronization of the wcf service itself. I solved it by using Wait and Pulse:
[WebMethod]
public string HelloWorld(int number)
{
string returnVal = "" ;
var command = new Command { Id = number };
lock(this)
{
Global.Bus.Send(command).Register<ErrorCodes>(code =>
{
lock(this)
{
returnVal = returnVal = Enum.GetName(typeof(ErrorCodes), code);
Monitor.Pulse(this);
}
}
);
Monitor.Wait(this);
}
return returnVal;
}
larserik
2010-01-08 11:18:50