开发者

How can I serialize handling of a .net web service?

I'm planning on using a .net web service to batch process database records. The web service requests are coming in from a SQL Server stored procedure that's called by SQL Server Agent every minute. I only want one batch to be running at a time because the whole point here is to avoid over loading the server.

Is there a good way of serializing the requests or maybe rejecting requests if there's already one in pr开发者_运维技巧ogress?

I was thinking of having a web service instance write a flag into the database that subsequent web service instances can read when they start up. If its already set then a web service will return without doing anything. A safe guard could be that if its been ten minutes, say, since the flag was set then the web service instance that set the flag would be considered to have failed.

Any thoughts?

Cheers, Ian.


You could use a static property on the web service to set when it's running, and other instances would check it (after appropriate locking) and fail gracefully, if so. That could take into account your time out, as well.

But is there not an easier way to do this? You seem to be talking about going back and forth from database to web service and back to database again, and for something you want running every minute. Something does not seem quite right. Is there a reason you can't use a Windows service, or even the Windows Task Scheduler?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜