This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Web Services and the fly likes Web Service and Transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web Service and Transaction" Watch "Web Service and Transaction" New topic
Author

Web Service and Transaction

C Shinde
Ranch Hand

Joined: Oct 22, 2009
Posts: 60
Hello,

I have a UI (basically a mobile client), which has a Button which when I clicked executes a process in the background. THis background process basically uploads data to the server via a webservice which is loaded into a DB. In the foreground after I click the button it shows a new screen with a progress bar and a cancel button below it. If I click the Cancel Button, I need to undo whatever data I have uploaded to the server via the web service.
The background process is executed via seperate thread in the client side that also calls the webservice.

I have a few questions:
1.Does this process qualify for a transaction kind of scenario?If yes how do I implement Transactions on Server side for this?
2. If this does not qualify for transaction what do I do? As I am building the background process as a seperate thread do I just stop the background thread if the cancel button is clicked, but then again the data already send to the Web Service, how will the webservice behave?

Any help Appreciated


Regards,
Chetan Shinde
Manan Panchal
Greenhorn

Joined: Nov 17, 2008
Posts: 19
Implement a method in webservice which simply set flag which can indicate that process is cancelled or not.
Execute the method when you hit "Cancel"
When your db changes finished check the flag, if process is cancelled then rollback transaction otherwise commit it.

Thanks
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
I would not attempt long-running transactions over the wild wild web. I would upload the data to a staging database. Once the data is uploaded, in addition to validating that the data is correct, move it to the regular database (using transactions). If the user clicks cancel then remove the loaded data from the staging database.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Web Service and Transaction
 
Similar Threads
How to tell one thread that another thread has finished
Communicating client interface actions to the server
consuming web services jsr 168 portlet
Do I need a separate Web Client?
Calling web services from Spring application