Announcement Announcement Module
Collapse
No announcement yet.
Implementing transaction around files storing service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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...

    Comment


    • #3
      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

      Comment

      Working...
      X