Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Web Service and Transaction

 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Manan Panchal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic