Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 68774 invoked from network); 21 Sep 2009 13:55:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Sep 2009 13:55:17 -0000 Received: (qmail 58478 invoked by uid 500); 21 Sep 2009 13:55:17 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 58455 invoked by uid 500); 21 Sep 2009 13:55:17 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 58445 invoked by uid 99); 21 Sep 2009 13:55:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Sep 2009 13:55:17 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.220.223 as permitted sender) Received: from [209.85.220.223] (HELO mail-fx0-f223.google.com) (209.85.220.223) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Sep 2009 13:55:05 +0000 Received: by fxm23 with SMTP id 23so2136185fxm.6 for ; Mon, 21 Sep 2009 06:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=lv0FknPD9c+rPyUpRNYwjwZZ49cN/ib5THcUh58fGbM=; b=fjemXsvM5z2taw3WAwuo+d2VeoJ50Hy0tGGzCjdAuMTt5wE+a3wLgCJIlh98FDusJG UYBrzuYfJ4yHbBOyTDWYrOtAXCNmhcxEVi95IboYTw2JSmaLDZqdt97T+brJuP9bUIyW y4d7FP37f9YkEcc6ZXOE84EVvTxhB2RiKyFZw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=ITyu8iM1Fw1OU5wKML90UsuTUpJGxbLdloUfop/nGXw1rHX/A40OSmtDXesd8D9qkn NnZIGzq+73Iwq6v+VqLK+JPBV+CqE0+gOuYD9pR3ZAfIu3KKtvmYV2oKGii1eC7ayn6y qfvUN8g89uvHI2eE6ZRa5YAY2PLqyR0FJ0bN4= MIME-Version: 1.0 Received: by 10.204.26.150 with SMTP id e22mr4308872bkc.68.1253541285169; Mon, 21 Sep 2009 06:54:45 -0700 (PDT) In-Reply-To: References: <5380c69c0909210450g29cb34md9b3757246b9fc87@mail.gmail.com> <5380c69c0909210459va513127ycdc97e4272966a68@mail.gmail.com> <5380c69c0909210512i7c2d3f34q4b054aeb2df1268f@mail.gmail.com> <5380c69c0909210614lde065a9qfcaf7a3135fcacaf@mail.gmail.com> From: Claus Ibsen Date: Mon, 21 Sep 2009 15:54:25 +0200 Message-ID: <5380c69c0909210654s129a39aegacefb4ef3dea8ec8@mail.gmail.com> Subject: Re: POJO consumer and Quartz To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Mon, Sep 21, 2009 at 3:46 PM, Charles Moulliard w= rote: > It works now except that I have the following error (btw, the objects > posted in the JMS queue are serializable) . > > CaughtExceptionType:java.io.NotSerializableException, > CaughtExceptionMessage:org.apache.camel.component.jms.JmsQueueEndpoint, > StackTrace:java.io.NotSerializableException: > org.apache.camel.component.jms.JmsQueueEndpoint > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeObject0(ObjectOutputStr= eam.java:1081) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeArray(ObjectOutputStrea= m.java:1251) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeObject0(ObjectOutputStr= eam.java:1075) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeObject(ObjectOutputStre= am.java:302) > =A0 =A0 =A0 =A0at org.apache.camel.component.bean.BeanInvocation.writeExt= ernal(BeanInvocation.java:104) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeExternalData(ObjectOutp= utStream.java:1310) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOu= tputStream.java:1288) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeObject0(ObjectOutputStr= eam.java:1079) > =A0 =A0 =A0 =A0at java.io.ObjectOutputStream.writeObject(ObjectOutputStre= am.java:302) > =A0 =A0 =A0 =A0at org.apache.activemq.command.ActiveMQObjectMessage.store= Content(ActiveMQObjectMessage.java:98) > > Why do we have to inject two times the reference of the uri, this is > not so very logic =A0 ? You do not need to. > > =A0 =A0 =A0 =A0@EndpointInject(name =3D "queueReportingEndpoint") > =A0 =A0 =A0 =A0private ConsumerTemplate consumer; > > =A0 =A0 =A0 =A0@EndpointInject(name =3D "queueReportingEndpoint") > =A0 =A0 =A0 =A0private Endpoint endpoint; > You can do this in a single line @EndpointInject(name =3D "queueReportingEndpoint") private ConsumerTemplate consumer; And then just as it then knows which endpoint to consume from as you specified it in the annotation Exchange e =3D consumer.receive(); 2) But if you want to have Endpoint and ConsumerTemplate then you can do @EndpointInject() private ConsumerTemplate consumer; @EndpointInject(name =3D "queueReportingEndpoint") private Endpoint endpoint; But then you need to tell the consumer template which endpoint to use Exchange e =3D consumer.receive(endpoint); Deposit 5$ to my pay pall account for support :) > Regards, > > Charles Moulliard > Senior Enterprise Architect > Apache Camel Committer > > ***************************** > blog : http://cmoulliard.blogspot.com > > > > On Mon, Sep 21, 2009 at 3:14 PM, Claus Ibsen wrot= e: >> Charles you do post your problems to soon. >> >> The NPE is of course because ConsumerTemplate is never initialized. >> >> Just add @EndpointInject to it as well >> >> @EndpointInject >> private ConsumerTemplate consumer; >> >> >> >> On Mon, Sep 21, 2009 at 3:06 PM, Charles Moulliard wrote: >>> There is something strange. I receive a NPE exception at the line >>> where I create an exchange from consumer : >>> >>> =A0 =A0 =A0 =A0@EndpointInject(name =3D "queueReportingEndpoint") >>> =A0 =A0 =A0 =A0private Endpoint endpoint; >>> >>> =A0 =A0 =A0 =A0private ConsumerTemplate consumer; >>> >>> =A0 =A0 =A0 =A0public List> collectMessages() { >>> >>> =A0 =A0 =A0 =A0Log.info("Endpoint : " + endpoint.getEndpointUri()); >>> >>> =A0 =A0 =A0 =A0Exchange exch =3D consumer.receive(endpoint); >>> >>> If I call directly consumer.receiveBody(endpoint, List.class); I have >>> the same error. I tough that the problem come from the endpoint >>> injection, but I have also a NPE if I use the uri of the endpoint in >>> the receiveBody method >>> >>> Here is the trace : >>> >>> Time=3DMon Sep 21 15:00:00 CEST 2009, calendar=3Dnull, >>> previousFireTime=3DMon Sep 21 14:58:00 CEST 2009, >>> CamelBeanMethodName=3Dnull}, BodyType:org.quartz.JobDetail, >>> Body:JobDetail 'DEFAULT.quartz://x3sReporting/clientError?cron=3D0+0%2F= 2+9-18+%3F+*+MON-FRI': >>> =A0jobClass: 'org.apache.camel.component.quartz.CamelJob isStateful: >>> false isVolatile: false isDurable: false requestsRecovers: false >>> 15:00:00,000 | INFO =A0| heduler_Worker-2 | x3s >>> =A0 =A0| rg.apache.camel.processor.Logger =A0 88 | Exchange[ >>> , BodyType:org.quartz.JobDetail >>> , Body:JobDetail >>> 'DEFAULT.quartz://x3sReporting/clientError?cron=3D0+0%2F2+9-18+%3F+*+MO= N-FRI': >>> =A0jobClass: 'org.apache.camel.component.quartz.CamelJob isStateful: >>> false isVolatile: false isDurable: false requestsRecovers: false >>> , CaughtExceptionType:java.lang.NullPointerException, >>> CaughtExceptionMessage:null, StackTrace:java.lang.NullPointerException >>> =A0 =A0 =A0 =A0at com.xpectis.x3s.core.util.ReportingConsumer.collectMe= ssages(ReportingConsumer.java:27) >>> >>> >>> Charles Moulliard >>> Senior Enterprise Architect >>> Apache Camel Committer >>> >>> ***************************** >>> blog : http://cmoulliard.blogspot.com >>> >>> >>> >>> On Mon, Sep 21, 2009 at 2:12 PM, Claus Ibsen wr= ote: >>>> On Mon, Sep 21, 2009 at 2:05 PM, Charles Moulliard wrote: >>>>> @EndpointInject(uri=3D"") only accepts as parameter an uri / name or >>>>> context but not a reference to a spring bean >>>>> >>>> >>>> Its the name attribute that is the ref, maybe we should rename it :) >>>> >>>> >>>> >>>>> Charles Moulliard >>>>> Senior Enterprise Architect >>>>> Apache Camel Committer >>>>> >>>>> ***************************** >>>>> blog : http://cmoulliard.blogspot.com >>>>> >>>>> >>>>> >>>>> On Mon, Sep 21, 2009 at 1:59 PM, Claus Ibsen = wrote: >>>>>> On Mon, Sep 21, 2009 at 1:55 PM, Charles Moulliard wrote: >>>>>>> Sorry for my mistake. >>>>>>> >>>>>>> I have used @consume because it was possible to pass as a parameter >>>>>>> the name of the endpoint to consume. Is there a way to do this with= a >>>>>>> consumer template ? >>>>>>> >>>>>> >>>>>> You can IoC the endpoint in the bean >>>>>> >>>>>> @EndpointInjected(ref =3D "foo") >>>>>> private Endpoint foo; >>>>>> >>>>>> but I would assume consumer template also works like producer templa= te with IoC >>>>>> ( if not we should add it) >>>>>> >>>>>> @EndpointInjected(ref =3D "foo") >>>>>> private ConsumerTemplate consumer; >>>>>> >>>>>> >>>>>> See more >>>>>> http://camel.apache.org/bean-injection.html >>>>>> >>>>>>> regards, >>>>>>> >>>>>>> Charles Moulliard >>>>>>> Senior Enterprise Architect >>>>>>> Apache Camel Committer >>>>>>> >>>>>>> ***************************** >>>>>>> blog : http://cmoulliard.blogspot.com >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Mon, Sep 21, 2009 at 1:50 PM, Claus Ibsen wrote: >>>>>>>> On Mon, Sep 21, 2009 at 1:46 PM, Charles Moulliard wrote: >>>>>>>>> The POJO defined in the following route consumes immediately mess= ages >>>>>>>>> posted on a queue and in consequence is not triggered by the Quar= tz >>>>>>>>> timer >>>>>>>>> >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0... >>>>>>>>> >>>>>>>>> public class ReportingConsumer { >>>>>>>>> >>>>>>>>> =A0 =A0@Consume(ref =3D "queueReportingEndpoint") // =3D x3s:repo= rt queue >>>>>>>>> =A0 =A0 =A0 =A0public List> collectMessages(L= ist>>>>>>>> Object>> received) { >>>>>>>>> >>>>>>>>> =A0 =A0 =A0 =A0List> result =3D new ArrayList= >(); >>>>>>>>> >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (received !=3D null) { >>>>>>>>> >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Log.info("Received= exchange : " + received.size()); >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0for(Map model : received) { >>>>>>>>> >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Lo= g.info("Map received : " + model.toString()); >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0//= Add model received into the result output list >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0re= sult.add( model ); >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >>>>>>>>> >>>>>>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return result; >>>>>>>>> =A0 =A0 =A0 =A0} >>>>>>>>> >>>>>>>>> Question : How can I avoid that the bean consumes immediately mes= sages >>>>>>>>> from the queue and wait quartz triggering ? >>>>>>>> >>>>>>>> You cannot as @Consume(ref =3D "queueReportingEndpoint") has ABSOL= UTELY >>>>>>>> nothing to do with quartz. >>>>>>>> It creates a new event driven consumer which listen on new message= s >>>>>>>> arriving on that JMS queue. >>>>>>>> >>>>>>>> You can remove the @Consume and then let quartz invoke it from the= Camel route. >>>>>>>> >>>>>>>> And then you can in your bean use a consumer template to read mess= ages >>>>>>>> from the JMS queue. >>>>>>>> Now you bean is only invoked when quartz triggers. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> Charles Moulliard >>>>>>>>> Senior Enterprise Architect >>>>>>>>> Apache Camel Committer >>>>>>>>> >>>>>>>>> ***************************** >>>>>>>>> blog : http://cmoulliard.blogspot.com >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Claus Ibsen >>>>>>>> Apache Camel Committer >>>>>>>> >>>>>>>> Open Source Integration: http://fusesource.com >>>>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>>>> Twitter: http://twitter.com/davsclaus >>>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Claus Ibsen >>>>>> Apache Camel Committer >>>>>> >>>>>> Open Source Integration: http://fusesource.com >>>>>> Blog: http://davsclaus.blogspot.com/ >>>>>> Twitter: http://twitter.com/davsclaus >>>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Claus Ibsen >>>> Apache Camel Committer >>>> >>>> Open Source Integration: http://fusesource.com >>>> Blog: http://davsclaus.blogspot.com/ >>>> Twitter: http://twitter.com/davsclaus >>>> >>> >> >> >> >> -- >> Claus Ibsen >> Apache Camel Committer >> >> Open Source Integration: http://fusesource.com >> Blog: http://davsclaus.blogspot.com/ >> Twitter: http://twitter.com/davsclaus >> > --=20 Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus