views:

98

answers:

3

I want to get progress updates about a method called on WCF.

For example I run 1000 queries and want to know the current status.

+3  A: 

Yes - use a duplex contract and report the progress every so often by using callbacks.

Mark Byers
+2  A: 

If a duplex contract is not workable in your environment, you will have to resort to polling. Your initial method could return an identifier (a GUID perhaps) and then you could make subsequent calls to another method to check the progress, and pass in the identifier.

This will obviously require you to store the progress information somewhere (like a session or a database), which is not great.

Bryan Batchelder
+2  A: 

That depends quite a bit on the services you are calling and how long you expect the operations to take.

If you are kicking off 1000 queries on a single service, you will likely get hit by the service throttling before all the calls to the service can be received.

There is a similar phenomenon on the client side. WCF will only allow so many concurrent calls at a time. This is configurable to some extent, but I would be surprised if 1000 concurrent calls would work without a hick-up or two.

If the calls end up being more or less synchronous, I would put all the queries in a queue and process each call in turn. You can then monitor the queue from your UI to update progress as calls to the service are completed.

If your architecture supports 1000 concurrent calls, then the duplex binding will be a good fit. You can just poll for completion.

Alternatively, you can create a pub / sub service that the target service updates as queries are completed. Your client would just catch events from the pub / sub service as the results from the queries become available.

Scott P
I would concur with processing in another app domain. NServiceBus Distributor example is a nice pattern. Since the workers report back to the Distributor, I bet you could report progress from that queue.
Adam Fyles
NServiceBus looks interesting. Will give it a try.
Rohit