Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Effective pattern for getting progress info about a method that takes a long time in WCF?

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.

like image 330
Rohit Avatar asked Dec 22 '09 21:12

Rohit


3 Answers

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.

like image 66
Bryan Batchelder Avatar answered Nov 07 '22 23:11

Bryan Batchelder


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

like image 38
Mark Byers Avatar answered Nov 08 '22 00:11

Mark Byers


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.

like image 20
Scott P Avatar answered Nov 07 '22 23:11

Scott P