Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Data Access

Reply
 
Thread Tools Display Modes
  #1  
Old Dec 18th, 2006, 05:15 AM
cyrille37 cyrille37 is offline
Junior Member
 
Join Date: Jul 2006
Posts: 22
Default Atomic File Transaction with Spring

Hello,

What I would like to do is to manage a transaction for a file upload with file's metadata. The transaction should manage the write of the file on the filesystem and the write of metadata in the database.

I did not found many documentation on Internet about Atomic File Transaction and specially none with Spring.
I've found 3 source of documentation:But I did not found or understand how to integrate those stuff with Spring Managed Transaction. I think it is not possible without adding many code.

Do you get a idea on how can I start the subject ?

Thanks,
Cyrille
Reply With Quote
  #2  
Old Dec 18th, 2006, 05:23 AM
karldmoore karldmoore is offline
Senior Member
 
Join Date: Sep 2006
Posts: 8,417
Default

I'm not sure if is possible, regardless of Spring. It there an OS independent way of doing this? I haven't seen an examples of this but I'll check out the ones you attached.
Reply With Quote
  #3  
Old Dec 18th, 2006, 05:57 AM
cyrille37 cyrille37 is offline
Junior Member
 
Join Date: Jul 2006
Posts: 22
Default

Quote:
Originally Posted by karldmoore View Post
but I'll check out the ones you attached.
Thanks a lot.

I'm a beginner with Java Application and it's a real BIG world where we have to make so many choises ...
I would be happy of reading your synthesis.

I am astonished that the Java & Spring World has not yet a solution for that common problem. We are often manipulating files and they should be managed in transactions to be safe like for database.

Regards,
Cyrille
Reply With Quote
  #4  
Old Dec 18th, 2006, 06:02 AM
karldmoore karldmoore is offline
Senior Member
 
Join Date: Sep 2006
Posts: 8,417
Default

I agree with what your saying, there are lots of frameworks, libraries, technologies etc...... Obviously can you do things like JMS and DB inside a transaction so it would be logical if file access could also participate. There may be something to already provide this, but I've not yet seen it.
Reply With Quote
  #5  
Old Dec 18th, 2006, 07:11 AM
dejanp dejanp is offline
Senior Member
 
Join Date: Sep 2004
Posts: 1,086
Default

Yes, it's a common problem, as old as file systems, but, it seems, not big enough to warrant a general solution.

It's the database server that implements transactions for the database. The role of the database server for files is taken by the OS, and that's the proper level where transactions should be implemented. Every other solution is, unavoidably, very brittle.

Now, considering the number of operating systems and file systems available, some of them implementing transactions, some not - I guess we would need something like "file system driver". I guess you could try raising an issue with Sun.
Reply With Quote
  #6  
Old Dec 18th, 2006, 07:15 AM
Costin Leau's Avatar
Costin Leau Costin Leau is offline
Spring DM Lead
Spring Modules TeamSpring Team
 
Join Date: Jan 2005
Location: Bucharest, Romania
Posts: 5,015
Default

The problem with the file systems is that most of them are not transactional and since the JDK has to be generic, the lowest common infrastructure has to be used.
You might want to look at JCR (Java Content Repository) which tries to address this problem along other by offering a unified API for dealing with storage (along with transactional support, a search language and export/import).
However, if you don't want to use another API, try adding your own mechanism usually by implementing a double-lock to make sure the transaction has succeeded.
__________________
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
Please use [ c o d e ] [ / c o d e ] tags
Reply With Quote
  #7  
Old Dec 18th, 2006, 08:15 AM
cyrille37 cyrille37 is offline
Junior Member
 
Join Date: Jul 2006
Posts: 22
Default

Quote:
Originally Posted by Costin Leau View Post
The problem with the file systems is that most of them are not transactional and since the JDK has to be generic, the lowest common infrastructure has to be used.
Yes, that's the problem.
Quote:
You might want to look at JCR (Java Content Repository) which tries to address this problem along other by offering a unified API for dealing with storage (along with transactional support, a search language and export/import).
Thanks for that new source of information.
Quote:
However, if you don't want to use another API, try adding your own mechanism usually by implementing a double-lock to make sure the transaction has succeeded.
I would like to do not write my own mechanism, but reusing an existing one.

But those I've found (see this thread's first post) seems to do not be integrated with standard Transaction api and could not ba integrated ASIS in Spring.

I'm surprised that those File Transaction mechanism has not been yet integrated with Java Transaction Standard and Spring.

Regards,
Cyrille
Reply With Quote
  #8  
Old Dec 18th, 2006, 08:29 AM
karldmoore karldmoore is offline
Senior Member
 
Join Date: Sep 2006
Posts: 8,417
Default

Quote:
Originally Posted by cyrille37 View Post
I'm surprised that those File Transaction mechanism has not been yet integrated with Java Transaction Standard and Spring.
If you looked at the comments of the URL you supplied, other people also talked about integration with JTA. I don't think you are on your own here. Might be worth adding a comment to see if anyone did actually do it?
Reply With Quote
  #9  
Old Dec 18th, 2006, 09:04 AM
cyrille37 cyrille37 is offline
Junior Member
 
Join Date: Jul 2006
Posts: 22
Default

Quote:
Originally Posted by karldmoore View Post
If you looked at the comments of the URL you supplied, other people also talked about integration with JTA. I don't think you are on your own here. Might be worth adding a comment to see if anyone did actually do it?
I'd added a coment to Atomic File Transactions, Part 2
and a Jira new feature to Commons-Transaction
Reply With Quote
  #10  
Old Dec 18th, 2006, 09:10 AM
Costin Leau's Avatar
Costin Leau Costin Leau is offline
Spring DM Lead
Spring Modules TeamSpring Team
 
Join Date: Jan 2005
Location: Bucharest, Romania
Posts: 5,015
Default

Seems that the article back at O'reilly is quite old... as for commons-tx, I was looking at it a couple of month ago and thinking of adding a bridge between Spring tx infrastructure and theirs but I'm not sure if the project is still active.
There aren't many releases and the last update was done in July.
__________________
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
Please use [ c o d e ] [ / c o d e ] tags
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:08 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.