开发者

Best practices to add some data into queue

I have a web application where users can upload the photo. I do have a windows service running which takes the uploaded photo and crops it to different sizes. This runs in a specified interval. Photo will be visible to the user once after it's cropped. So once user uploads the photo and photo cropper has not yet run, they wont be able to see the photo. Due to this behaviour user thinks that there was some error uploading the photo and they will upload it again and again.

Can any one suggest me some queuing mechanism where the p开发者_如何学Pythonhotocropper runs immediately when the user uploads the photos which is queued.

I am using asp.net & C#.

Please let me know if i am confusing.


Using NService bus is a best option I think.Using NService bus you can handle a message as soon as it is avliable in queue.You can host your NService application as a window service as well. NSerivice Bus


Microsoft Message Queue (MSMQ) is natively available in .Net. You can pass in your own types and read them out in your Windows Service as long as you have a shared DLL containing a common interface / the concrete implementation.

Obviously it needs to be installed on the server, but is generally part of the default installation.


Personally, I think that what you are trying to do - crop a photo that is uploaded, should't take too long, and as someone suggested on the comment to the question, do you need the overhead of creating an infrastructure where the work is queued and processed out-of-process by another application? Is this going to happen a lot (how many photo crop requests per sec/min?). Instead can you not just send the request via AJAX to the server, and have some form of "please wait" animation on the browser until the request eventually comes back and the photo is cropped?

If you do think you need to go down the queue approach, then I'd suggest MSMQ, because it's very simple to work with - see the example code here

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜