Quite late but ... On 03.02.2006 20:48, Dominique wrote:
I have a Cocoon Action that takes a lot of time and adds new entries to an XML document (Lenya's sitetree.xml). I have put this action inside a different Thread so the user can continue browsing without having to wait to long: However, when a user requests some pages during this background processing, the sitetree.xml is loaded and is sometimes in an inconsistent state (see end). I guess this is when the save() operation is writing its output and a user requests the page. Is there some way of preventing Cocoon to process the sitetree.xml while it is being written to ? Or any other suggestions for performing a task in the background ?
Your problem is simply a transactional access to the file system. You have two options: You can let the action create the sitetree.xml at another place and only copy/move it at the end to the place where it is needed. This will at least reduce the possibility of an access to this file at the same time.
A probably more secure way of handling this would be to use Jakarta Commons Transaction. It provides transactional access to the filesystem to a certain extent. It only provides pessimistic locking, i.e. while the background task has a lock on the file, nobody can read it.
Maybe the mixture of both methods is the best way to handle this. Jörg --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
