queue on WCF web service - can you implement something like a background task

I have a service that does image processing on an image supplied by the client. Each processing takes CPU (3min aprox runtime/image), so I will not allow more than 1 image to be processed at a time.

what I did is that when the service is called, the image is saved on the server and an entry is added into the database, with the status queued.

Now I would like to create a background task or something that takes every entry from the database that has a status Queued, processes that image,updates the entry status to Done, and than takes the new entry with the status Queued and so on.

There may be the case that no image is queued at some time.

How do you suggest me implementing this?

Answers


You could use Windows Server AppFabric to host a workflow-backed WCF service. Instead of service.svc, the extension is service.xamlx. AppFabric is designed to run long running processes like this and will scale to your needs.


It sounds like what you want is a queued service.

http://msdn.microsoft.com/en-us/library/ms731089.aspx

It allows you to focus on your core algorithm and not worry much about the mechanics of queuing the messages (e.g. making custom DB tables for queues etc.). Queuing sounds easy, but to get it to work reliably is harder than it sounds - better to leave it to the experts at MS :o)

It also provides some good features like durability, poison message handling etc.


Perhaps you can develop a windows service which polls the database every minute for any images to process.


Need Your Help

Windows alt + tab causes windowed mode

windows fullscreen cocos2d-x marmalade

I'm using marmalade 6.2 and cocos 2.1 beta3.x.2.1. When I deploy a windows build in fullscreen mode alt tabbing out and back into the application causes the application to go to windowed mode. Is t...

Is there any memory loss in HDFS if we use small files?

hadoop hdfs

I have taken below Quoting from Hadoop - The Definitive Guide:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.