You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Dominique <op...@gmail.com> on 2006/02/03 20:48:07 UTC

background Action - temporary lock xml file for cocoon requests

Hi all,

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:

act(..) {

       Thread approveThread = new Thread(this);
       approveThread.start();
return null;
}

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 ?

thx,

Dominique De Munck



"
org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.xml.sax.SAXParseException: XML document structures must start and
end within the same entity.

column: 4

line: 858

cause: org.xml.sax.SAXParseException: XML document structures must
start and end within the same entity.

location: file:/home/devel/web_software/web_software/tomcat-5.0.28/webapps/lenya/lenya/pubs/ParlementaireActiviteiten/content/authoring/sitetree.xml
"

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: background Action - temporary lock xml file for cocoon requests

Posted by Dominique <op...@gmail.com>.
fortunatly, it's not a public website, it's only accessed by a few editors.


> > act(..) {
> >
> >        Thread approveThread = new Thread(this);
> >        approveThread.start();
> > return null;
> > }
>
> Autsch! Well, then you better don't have many user ;)
>
> Every request generates a thread - that makes it really easy to bring
> down that machine
>
> cheers
> --
> Torsten
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: background Action - temporary lock xml file for cocoon requests

Posted by Torsten Curdt <tc...@apache.org>.
On 04.02.2006, at 06:48, Dominique wrote:

> Hi all,
>
> 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:
>
> act(..) {
>
>        Thread approveThread = new Thread(this);
>        approveThread.start();
> return null;
> }

Autsch! Well, then you better don't have many user ;)

Every request generates a thread - that makes it really easy to bring  
down that machine

cheers
--
Torsten

Re: background Action - temporary lock xml file for cocoon requests

Posted by Joerg Heinicke <jo...@gmx.de>.
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org