Results 1 to 3 of 3

Thread: Implementing transaction around files storing service

  1. #1
    Join Date
    Jun 2009
    Location
    Poland, Warsaw
    Posts
    33

    Default Implementing transaction around files storing service

    Hi,
    I'd like to implement a service to store files on mass storage. Let's see some code sample as follow:
    Code:
    class Something implements StoreBean {
         // bla bla bla some attributes
         private String path;
         // getters and setters of course bla bla bla
    }
    
    interface StoreBean {
         public String getPath();
    }
    What is a idea ? Shortly... service implementing declarative transactions should save 'Something' object to database, save some file indicated by 'path' attribute on disk, and ... if db transaction fails, some transactionmanager should delete file from disk. I need some advices, what is a best solution to above scenario ??

    Regards

    Tom

  2. #2

    Default

    Apache Commons Transactions has some implementation for that, which I used in the past for a Transactional-In-Mem-Data-Structure. Not sure about the project state, but I see it moved from sandbox to the main projects

    See http://commons.apache.org/transaction/

    I'm sure there are also many more ready to use open source projects out there that can save you the trouble of having to reinvent the wheel...

  3. #3
    Join Date
    Mar 2010
    Posts
    11

    Default

    Hi,

    Using XA transactions you can combine operations across multiple resources in a single global transaction. This would guarantee that either all of the operations commit or none of them commit. You need to configure your database's data-source to enable XA with database. As file-systems do not support XA, you can use XADisk to perform the file operations inside XA transactions.

    Hope that helps.

    Thanks,
    Nitin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •