-
1. Re: threads concurrency issue while writing to text files
banzeletti Aug 23, 2012 12:09 PM (in response to gudepier)Excellent question since file I/O is not supported by JEE. As far as I percieve the situation synchronization depends on you, the application developer. There used to be some JCA adapters for File I/O including transation (isolation) support, but since they came by commercial licence I've never tried those by myself. Maybe meanwhile things have improved...
My considerations so far include:
1) provide a file server EJB .- maybe a @Singleton - that grants file access to clients and uses a database (JTA) to manage locks on files
2) make a CDI @Conversation or @Session the client of the file server
However, doing this at professional quality seems to be a tremendous amount of work (can more than one client concurrently read a file? file renames? stale locks? @Rollback support? ....). This is where I quit pursuing this concept.
On the other hand, modern databases all provide "BLOB"s so a file system can easily be emulated by a database... not the perfect match of technologies, but much simpler.