tags:

views:

158

answers:

5

I have an application built that hits a third party company's web service in order to create an email account after a customer clicks a button. However, sometimes the web service takes longer than 1 minute to respond, which is way to long for my customers to be sitting there waiting for a response.

I need to devise a way to set up some sort of queuing service external from the web site. This way I can add the web service action to the queue and advise the customer it may take up to 2 minutes to create the account.

I'm curious of the best way to achieve this. My initial thought is to request the actions via a database table which will be checked on a regular basis by a Console app which is run via Windows Scheduled tasks.

Any issues with that method?

Is there a better method you can think of?

+10  A: 

I would use MSMQ, it may be an older technology but it is perfect for the scenario you describe.

Otávio Décio
MSMQ is still being actively worked on. MSMQ 5 was just released with Win7 and W2K8 R2.
Paul Kearney - pk
Note that you can use MSMQ through WCF if you so desire.
Nelson
Also, to use MSMQ you will have to install it, since it's not done by default. It does guarantee message delivery, etc. which could work well.
Nelson
+1  A: 

Create a WCF service to manage the queue and it's actions. On the service expose a method to add an action to the queue.

This way the queue is completely independent of your website.

Stephan
A: 

What about the Queue Class or Generic Queue Class?

Dinah
+1  A: 

What if you use a combination of AJAX and a Windows Service?

On the website side: When the person chooses to create an e-mail account, you add the request to a database table. If they want to wait, provide a web page that uses AJAX to check every so often (10 seconds?) whether their account has been created or not. If it's an application-style website, you could let them continue working and pop up a message once the account is created. If they don't want to wait, they close the page or browse to another and maybe get an e-mail once it's done.

On the processing side: Create a Windows service that checks the table for new requests. Once it's done with a request it has to somehow communicate back to the user, maybe by setting a status flag on the request. This is what the AJAX call would look for. You could send an e-mail at this point too.

If you use a scheduled task with a console app instead of a Windows service, you risk having multiple instances running at the same time. You would have to implement some sort of locking mechanism (at the app or request level) to prevent processing the same thing twice.

Nelson
Something I JUST learned. You don't have to poll every x seconds. Use a long poll, comet, reverse ajax, whatever you want to call it. It's still technically a poll, but the server holds on to the connection until it has data. AJAX is asynchronous, so it's not a problem to keep it open.
Nelson
A: 

Unfortunetally, your question is too vague to answer with any real detail. If this is something you want managed outside the primary application then a Windows Service would be a little more appropriate then creating a Console... From an integration and lifecycle management perspective this provides a nice foudation for adding other features (e.g. Performance Counters, Hosted Management Services in WCF, Remoting, etc...). MSMQ is great although there is a bit more involved in deployment. If you are willing to invest the time, there are a lot of advantanges to using MSMQ. If you really want to create your own point to point queue, then there are a ton of examples online that can serve as an example. Here is one, http://www.smelser.net/blog/page/SmellyQueue-(Durable-Queue).aspx.

JoeGeeky