Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Generic Transaction Management

I am developing a java server that stores files on Amazon S3. I need to have transaction management with S3 such that if an operation to an external server fails every file that was saved to S3 must be rollback.

It is basically like transaction management to the database except that the data source in this case is AWS S3, it could have been the file system as well.

I was unable to find existing technologies and was wondering if I just need to implement it or a library/technology exists already for that.

Thx in advance.

like image 814
isaac.hazan Avatar asked Oct 14 '25 16:10

isaac.hazan


1 Answers

There isn't any out of the box way to implement the transaction management; so you have hand code the logic and implementation on your own.

The one advantage you have with respect to the S3 is that, you will never get a dirty read or dirty write. S3 will always gives you the completely processed file ( blob ) although even if it is being currently written. This kind of reduces the burden to putting the efforts in implementation of the critical section, locking etc. It is directly supported by AWS.

So the way I suggest the implementation of the Transaction process is

  • Do the initial process and call servers / services ( as you mentioned )
  • If that works fine then push the data to S3
  • if the call / process for the data has failed you will do nothing

The other alternative is to push the data to S3, if in the event of roll-back transaction requirement you may delete the S3 key

This might sound subtle but that't how it is, the question scope is broad.

like image 138
Naveen Vijay Avatar answered Oct 17 '25 06:10

Naveen Vijay