views:

67

answers:

3

Hello,

We have a predominantly RESTful architecture for our product. This enables us to nicely implement almost all of the required functionality, except this new requirement thats come in.

I need to implement a page which lets the user to large scale DB operations synchronously. They can stop the operation in between, if they realized they made a mistake (rather than waiting for it to complete and doing an undo operation)

I was wondering if some one could give some pointers as to what would be the best way to implement such a functionality?

Cheers! Nirav

+1  A: 

How about a resource that encapsulates a set of batch operations? Creating the resource means kicking off the operations (data to indicate what the operations should do is submitted via POST). Updating the resource allows stopping it or modifying it while processing.

JacobM
A: 

I would kick off the large operation in a separate thread. Show the user a constantly updated status of the thread, along with a Cancel button. If the user clicks the Cancel button, you kill thread.

This is the way I've implemented similar things in the past.

The idea is to give them their control back immediately, but don't let them do anything else until the thread is complete except cancel.

In generic terms, you need a "job queue" and a way to manage the queue.

Marcus Adams
A: 

You need to integrate a batch manager, or implement your own. There are several products that can help you. As an example, read this article http://www.ibm.com/developerworks/websphere/techjournal/0801_vignola/0801_vignola.html

PA