Justin
Justin

Reputation: 45350

How To Queue Work To Be Done By The Server ASP.NET

We have a CSV uploader where users can upload a CSV file filled with address, city, state, zipcode. The CSV files can be hundreds, thousands, even 10's of thousands of rows.

We need to geocode the rows; no problem, we are using Google Maps RESTFul Web Service, but I don't want to make the user wait while we geocode every row (it can take some time). Basically, I want the upload to complete, and then magically, pass the geocode job off to the server, and allow the user to continue navigating the web app, while the geocodes happen in the background.

I think, this system, requires a queue or job based software; maybe ZeroMQ or RabbitMQ? I have no experience with this, so baby feeding would be amazing. We are using ASP.NET C#.

Upvotes: 4

Views: 688

Answers (3)

Jacob
Jacob

Reputation: 78840

Your idea to use queuing is sound. WCF with MSMQ endpoints is an alternative to third-party queuing technologies if you're developing for Windows boxes.

Upvotes: 3

Andrew M
Andrew M

Reputation: 9459

This should be possible by spinning up a new thread, onto which you pass the geocoding work, then returning the page response to the user as normal. This question covers much the same problem.

You could try something like:

ThreadPool.QueueUserWorkItem(delegate {
    DoGeocoding(state details);
});

You may or may not need to call Response.Flush after that to return the current page request, and allow the user to carry on browsing.

Upvotes: 2

mbeckish
mbeckish

Reputation: 10579

An alternative to message queue software would be to use a database to track the CSV processing requests.

Your CSV processing code can update the table as the status of each request changes.

Your ASP.NET site can query the table to display the status of each request to the users.

Upvotes: 1

Related Questions