user710818
user710818

Reputation: 24248

Coordinated save in database and disk in java

In my task I need to save file on disk and update info about in database. Exception can happen when saving file and when updating info in database. Do exist some ready open source solutions for it or it need write from scratch? Thanks.

Upvotes: 1

Views: 317

Answers (3)

Nicholas
Nicholas

Reputation: 16056

There's XADisk which provides transactional access to file systems. From their web site:

XADisk (pronounced 'x-a-disk') enables transactional access to existing file systems by providing APIs to perform file/directory operations. With simple steps, it can be deployed over any JVM and can then start serving all kinds of Java/JavaEE application running anywhere.

Upvotes: 3

Grooveek
Grooveek

Reputation: 10094

In Java, enterprise transactions management is ruled by the JTA spec wich is used in Java EE.

JTA allows to create several TransactionManager with differents implementations (one for database, one for file) and make them work together to define a cross-transaction I think this could be a way for you to do what you want

Outside of a container, there are possibility to integrate JTA. You should have a look at Spring or JBoss implementations

Look at this blog post for more information about Spring and transactions usage

Upvotes: 1

Puce
Puce

Reputation: 38132

The file system isn't directly supported by Java EE, but you could implement/ search for a resource adapter for the file system.

http://docs.oracle.com/javaee/6/tutorial/doc/gipgl.html

http://docs.oracle.com/javaee/6/tutorial/doc/giqjk.html

Upvotes: 0

Related Questions