I am investigating NServiceBus and I am unsure how (or even if) I could use it to handle this scenario:
I have multiple clients sending work requests, which the distributor farms out to workers. The work will take a long time to complete and I would like the workers to report progress back to the client that sent the original request.
I have looked at the full duplex sample and also how to add the distributor to that sample. I've got these working, but when I modify them to reply with a series of progress messages (with a delay between the messages, as per code shown below), the client receives all the progress messages at the same time.
public class RequestDataMessageHandler : IHandleMessages<RequestDataMessage>
{
public IBus Bus { get; set; }
public void Handle(RequestDataMessage message)
{
for (var i = 0; i < 10; i++)
{
var count = i;
var response = this.Bus.CreateInstance<DataResponseMessage>(m =>
{
m.DataId = message.DataId;
m.Progress = count * 10;
});
this.Bus.Reply(response);
Thread.Sleep(1000);
}
}
}
I suspect I've not understood something basic about how NServiceBus works. Could someone explain where I've gone wrong, or point me at some examples and/or documentation?