Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 69038 invoked from network); 18 Dec 2005 03:10:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Dec 2005 03:10:50 -0000 Received: (qmail 5685 invoked by uid 500); 18 Dec 2005 03:10:37 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 5666 invoked by uid 500); 18 Dec 2005 03:10:37 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 5647 invoked by uid 99); 18 Dec 2005 03:10:36 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Dec 2005 19:10:36 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of Oliver.Powell@tvnz.co.nz designates 202.36.33.204 as permitted sender) Received: from [202.36.33.204] (HELO akironport.tvnz.co.nz) (202.36.33.204) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Dec 2005 19:10:35 -0800 Received: from unknown (HELO saturn.tvnz.co.nz) ([192.168.10.21]) by akironport.tvnz.co.nz with ESMTP; 18 Dec 2005 16:10:13 +1300 Received: from AK1VXCH01.tvnzad.tvnz.co.nz ([202.36.33.100]) by saturn.tvnz.co.nz with InterScan Messaging Security Suite; Sun, 18 Dec 2005 16:10:13 +1300 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: JMS Listener invokes Cocoon pipeline (RE: How do I create a context from a background task in cocoon?) Date: Sun, 18 Dec 2005 16:10:21 +1300 Message-ID: <9CF7E05EDC0455439ABF5CD929818F66856F01@AK1VXCH01.tvnzad.tvnz.co.nz> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: JMS Listener invokes Cocoon pipeline (RE: How do I create a context from a background task in cocoon?) Thread-Index: AcX6q7FPIgqKF9lIRoSR8O+IcpsglgI0MWPQ From: "Oliver Powell" To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, we've got a similar need to invoke Cocoon in the background:=0D We have a JMS Listener component configured to startup when Cocoon starts up (in cocoon.xconf). When its asynch onMessage() method is called, we want the method to then invoke a Cocoon pipeline. We expect the JMS topic to be pushing a steady, reasonably constant supply of messages every few seconds or less, sometimes there will be spikes. What is the best way to implement this? Our current implementation uses the BackgroundEnvironment class from the cron block that Sylvain Wallez mentions below. Unfortunately however, under our soak test the server collapses after 24 hours with a java.lang.OutOfMemory error.=0D One thing I can see I've probably done wrong is I fully establish the Cocoon environment entirely within the onMessage() method, every time. That's a lot of work to do for EVERY message we get. So should I instead establish the BackgroundEnvironment (and lookup the SourceResolver) on initialisation of the Listener component? Then the only work performed within onMessage is to call SourceResolver.resolveURI()? If so, exactly how much setup should I do in initialise()? Is it ok if it goes as far as: ... CocoonComponentManager.enterEnvironment(env, new WrapperComponentManager(this.manager), processor); this.resolver =3D (SourceResolver) this.manager.lookup(SourceResolver.ROLE); Then in onMessage() I can simply call: src =3D this.resolver.resolveURI(uri); At what point should I close down and clean up the BackgroudEnvironment? In dispose()? I'm a bit nervous using BackgroundEnvironment and CocoonComponentManager in this way - especially when the CocoonComponentManager javadoc says 'WARNING: This is a "private" Cocoon core class - do NOT use this class directly'! I'm tempted to instead have the onMessage() method simply make an http request to the "proper" Cocoon environment on localhost:8080. It feels like it would be the safer way to go. Then I can let the normal CocoonServlet look after the environment. (Also note, I'd rather not use the cron block). Any advice? Thanks in advance, Oliver Powell -----Original Message----- From: Sylvain Wallez [mailto:sylvain@apache.org]=0D Sent: Wednesday, 7 December 2005 10:26 a.m. To: users@cocoon.apache.org Subject: Re: How do I create a context from a background task in cocoon? Ard Schrijvers wrote: > Does anybody have experience with calling a pipeline from a background task resulting from an eventHandler? > > So, on an event, a java class is executed which implements Contextualizable. > > I am trying something like > > import org.apache.avalon.framework.context.Contextualizable; > import org.apache.avalon.framework.context.Context; > import org.apache.avalon.framework.context.ContextException; > > implements Contextualizable, ... > > private Context context; > > public void contextualize(Context context) throws ContextException { > this.context =3D context; > > } > PipelineUtil pipeUtil =3D new PipelineUtil(); try { > pipeUtil.contextualize(context); > pipeUtil.service(serviceManager); > pipeUtil.processToSAX(uri, null, somehandler); } catch (Exception=0D > e) { > throw new CascadingRuntimeException("Cannot process pipeline from=0D > '" + uri + "'", e); } finally { > pipeUtil.dispose(); > } > > Now, this does not work, because it does not have a context, since the class is not called from a sitemap but from an external event. > > So, I tried instead of with the context, the SourceResolver, like > > SourceResolver resolver =3D (SourceResolver)=0D > manager.lookup(SourceResolver.ROLE); > > and then something like > Source inputSource =3D=0D > resolver.resolveURI("cocoon://dasl/references/content/test/Passage.xml > "); > > But, nothing happens, I suppose because the cocoon:// is only=0D > available when the call is initiated from a sitemap (or flow of=0D > course) > > So, does anybody know how to solve this/solved this before? > =0D Yes. Running a Cocoon pipeline in a background task requires to setup a "fake" environment so that the SourceResolver can do its job. You can achieve that either by using the scheduler (cron block) to fire a job immediately, or directly use the BackgroundEnvironment class that it uses under the hoods. Sylvain --=0D Sylvain Wallez Anyware Technologies http://bluxte.net http://www.anyware-tech.com Apache Software Foundation Member Research & Technology Director --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CAUTION: This e-mail and any attachment(s) contains information that=0D is intended to be read only by the named recipient(s). It may contain=0D information that is confidential, proprietary or the subject of legal=0D privilege. This information is not to be used by any other person=0D and/or organisation. If you are not the intended recipient, please=0D advise us immediately and delete this e-mail from your system. Do not=0D use any information contained in it. =0D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D For more information on the Television New Zealand Group, visit us=0D online at http://www.tvnz.co.nz=0D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org