Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 49782 invoked from network); 30 Aug 2009 09:58:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Aug 2009 09:58:28 -0000 Received: (qmail 20346 invoked by uid 500); 30 Aug 2009 09:58:27 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 20283 invoked by uid 500); 30 Aug 2009 09:58:27 -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 20273 invoked by uid 99); 30 Aug 2009 09:58:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Aug 2009 09:58:27 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Aug 2009 09:58:16 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1MhhAZ-0001eh-6k for users@camel.apache.org; Sun, 30 Aug 2009 02:57:55 -0700 Message-ID: <25210156.post@talk.nabble.com> Date: Sun, 30 Aug 2009 02:57:55 -0700 (PDT) From: Seb- To: users@camel.apache.org Subject: Re: Transaction and Multicast() or to() AND to() ? In-Reply-To: <5380c69c0908300228r2340b7eapecdce73bcd26ea0d@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: seba.public@gmail.com References: <5380c69c0905190043w5692688vd7e8ba4e6a80654e@mail.gmail.com> <5380c69c0905190103p49c22b62kda3879a9fac98660@mail.gmail.com> <25205618.post@talk.nabble.com> <5380c69c0908300009u67171634ie62ee4232c7b73be@mail.gmail.com> <25209498.post@talk.nabble.com> <5380c69c0908300130q1a493e18t5bab7e9fa7a1858e@mail.gmail.com> <25209959.post@talk.nabble.com> <5380c69c0908300228r2340b7eapecdce73bcd26ea0d@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org I see, yes I can keep the jdbc stuff in the same thread (possibly I will ad= d an entry route and end route dealing with the jdbc stuff). Thank you very much for your help! And keep on the good job on camel. Claus Ibsen-2 wrote: >=20 > On Sun, Aug 30, 2009 at 11:21 AM, Seb- wrote: >> >> The process do heavy cpu/time consuming process for each message it >> receives, >> then it sets the Exchange with the result. >> It is parallelized to maximize the throughput. And it should be >> transacted >> from 1st endpoint to last one as the message will be processed through >> other >> routes (which might be multithreaded aswell), and if the whole route pat= h >> executed without any exception then a remove/insert will occur in the >> database (just like the TransactionalClientDataSourceTest example). >> >=20 > If you can keep the JDBC stuff in the same thread as the starting > thread (the one that has the policy(required) =3D the spring TX manager) > then it should not matter if the CPU jobs are done in other threads. > As long all what Spring TX manager needs to leverage is done from the > same thread. >=20 > In reality one a few transports supports TX such as JMS and JDBC. If > you are not using JMS then its only left with JDBC. > How much do you need to use the JDBC? If its only the last operation > doing either insert/remove then its easier. >=20 > I suggest to create a smaller unit test prototype with a route path > simulating what you want to do. >=20 >=20 >=20 >=20 >> >> Claus Ibsen-2 wrote: >>> >>> On Sun, Aug 30, 2009 at 9:58 AM, Seb- wrote: >>>> >>>> In fact the input is not a JMS Queue. It's just that I need several >>>> threads >>>> to parallelize a .process(). >>>> >>> >>> What does the process do? Depending on what it does you could do it >>> and still use transactions. >>> Its just that the parallel tasks are using another thread and thus >>> spring TX is affected. >>> >>> >>> >>>> >>>> Claus Ibsen-2 wrote: >>>>> >>>>> On Sat, Aug 29, 2009 at 9:18 PM, Seb- wrote: >>>>>> >>>>>> Hi Claus, >>>>>> Do you have a work around to get transacted (basically transaction) >>>>>> working >>>>>> with multiple threads. >>>>>> ie get this from TransactionalClientDataSourceTest (where fails >>>>>> and/or >>>>>> okay >>>>>> route have threads(x)) to rollback: >>>>>> >>>>> >>>>> No that is not possible as its spring transaction that is doing the >>>>> actual TX and it only supports doing that in the same synchronous >>>>> thread. >>>>> >>>>> But if you input is from a JMS queue then set the >>>>> concurrentConsumers=3D5 on the JMS endpoint and you have 5 threads at >>>>> same time running in their own thread which all can be transacted. >>>>> >>>>> >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from("direct:= shouldrollback").policy(required). >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0to("direct:okay"). >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0to("direct:fail"); >>>>>> >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from("direct:= okay").policy(required). >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0setBody(constant("Tiger in >>>>>> Action")).beanRef("bookService"). >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0setBody(constant("Elephant in >>>>>> Action")).beanRef("bookService"); >>>>>> >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// set the re= quired policy for this route >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from("direct:= fail").threads(5).policy(required). >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0setBody(constant("Tiger in >>>>>> Action")).beanRef("bookService"). >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0setBody(constant("Donkey in >>>>>> Action")).beanRef("bookService"); >>>>>> >>>>>> Thanks, >>>>>> S=C3=A9bastien. >>>>>> >>>>>> >>>>>> Claus Ibsen-2 wrote: >>>>>>> >>>>>>> On Tue, May 19, 2009 at 9:58 AM, Charles Moulliard >>>>>>> >>>>>>> wrote: >>>>>>>> Thanks Claus. >>>>>>>> >>>>>>>> Additional question : >>>>>>>> >>>>>>>> Can =C2=A0two routes be part of the same transaction ? >>>>>>> Yes as long as they run in the same thread, eg as you do link them >>>>>>> with >>>>>>> direct. >>>>>>> Do not use seda as it will break it into 2 threads. >>>>>>> >>>>>>> Spring TX manager uses the same thread for its TX management. >>>>>>> >>>>>>> >>>>>>>> >>>>>>>> ex : >>>>>>>> >>>>>>>> >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 >>>>>>>> >>>>>>>> =C2=A0 >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 =C2=A0 >>>>>>>> =C2=A0 >>>>>>>> >>>>>>>> Regards, >>>>>>>> >>>>>>>> >>>>>>>> Charles Moulliard >>>>>>>> Senior Enterprise Architect >>>>>>>> Apache Camel Committer >>>>>>>> >>>>>>>> ***************************** >>>>>>>> blog : http://cmoulliard.blogspot.com >>>>>>>> >>>>>>>> >>>>>>>> On Tue, May 19, 2009 at 9:43 AM, Claus Ibsen >>>>>>>> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> On Tue, May 19, 2009 at 9:11 AM, Charles Moulliard >>>>>>>>> >>>>>>>>> wrote: >>>>>>>>> > Hi, >>>>>>>>> > >>>>>>>>> > I would like to know if the transactional behavior of >>>>>>>>> camel/spring >>>>>>>>> will >>>>>>>>> be >>>>>>>>> > the same comparing the two next routes : >>>>>>>>> > >>>>>>>>> > 1) Multicast >>>>>>>>> > >>>>>>>>> > from() >>>>>>>>> > transacted() >>>>>>>>> > multicast( >>>>>>>>> > to(bean:update DB) >>>>>>>>> > to(queue:IN) >>>>>>>>> > ) >>>>>>>>> > >>>>>>>>> > 2) To() and to() >>>>>>>>> > >>>>>>>>> > from() >>>>>>>>> > transacted() >>>>>>>>> > to(bean:update DB) >>>>>>>>> > to(queue:IN) >>>>>>>>> > >>>>>>>>> >>>>>>>>> Yes the TX is the same. >>>>>>>>> >>>>>>>>> >>>>>>>>> > Does it make sense to multicast messages when we want that data >>>>>>>>> > updated/inserted DB are rollbacked if an error occurs during >>>>>>>>> creation >>>>>>>>> of >>>>>>>>> the >>>>>>>>> > message on the queue OR messages removed from the queue if an >>>>>>>>> errors >>>>>>>>> occurs >>>>>>>>> > during DB update ? >>>>>>>>> >>>>>>>>> Spring TX manager will rollback the TX if it was marked for >>>>>>>>> rollback >>>>>>>>> or it caughts a runtime exception. >>>>>>>>> So whatever you from the transacted() onwards will occur in the >>>>>>>>> same >>>>>>>>> TX. >>>>>>>>> >>>>>>>>> Using either .to or .multicast has really nothing to do with TX. >>>>>>>>> >>>>>>>>> The former is the Pipes And Filters EIP where output from the >>>>>>>>> previous >>>>>>>>> is input to the next and so forth. >>>>>>>>> The latter is the Recipient List EIP where you send the *same* >>>>>>>>> message >>>>>>>>> to multiple recipients. >>>>>>>>> >>>>>>>>> >>>>>>>>> > >>>>>>>>> > Regards, >>>>>>>>> > >>>>>>>>> > 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 >>>>>>> >>>>>>> >>>>>> >>>>>> -- >>>>>> View this message in context: >>>>>> http://www.nabble.com/Transaction-and-Multicast%28%29-or-to%28%29-AN= D-to%28%29---tp23610919p25205618.html >>>>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Claus Ibsen >>>>> Apache Camel Committer >>>>> >>>>> Open Source Integration: http://fusesource.com >>>>> Blog: http://davsclaus.blogspot.com/ >>>>> Twitter: http://twitter.com/davsclaus >>>>> >>>>> >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/Transaction-and-Multicast%28%29-or-to%28%29-AND-= to%28%29---tp23610919p25209498.html >>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>> >>>> >>> >>> >>> >>> -- >>> Claus Ibsen >>> Apache Camel Committer >>> >>> Open Source Integration: http://fusesource.com >>> Blog: http://davsclaus.blogspot.com/ >>> Twitter: http://twitter.com/davsclaus >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Transaction-and-Multicast%28%29-or-to%28%29-AND-to= %28%29---tp23610919p25209959.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >=20 >=20 >=20 > --=20 > Claus Ibsen > Apache Camel Committer >=20 > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus >=20 >=20 --=20 View this message in context: http://www.nabble.com/Transaction-and-Multica= st%28%29-or-to%28%29-AND-to%28%29---tp23610919p25210156.html Sent from the Camel - Users mailing list archive at Nabble.com.