Return-Path: Delivered-To: apmail-activemq-camel-user-archive@locus.apache.org Received: (qmail 28216 invoked from network); 8 Jan 2009 19:42:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jan 2009 19:42:19 -0000 Received: (qmail 10692 invoked by uid 500); 8 Jan 2009 19:42:18 -0000 Delivered-To: apmail-activemq-camel-user-archive@activemq.apache.org Received: (qmail 10677 invoked by uid 500); 8 Jan 2009 19:42:18 -0000 Mailing-List: contact camel-user-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: camel-user@activemq.apache.org Delivered-To: mailing list camel-user@activemq.apache.org Received: (qmail 10666 invoked by uid 99); 8 Jan 2009 19:42:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2009 11:42:18 -0800 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.218.15 as permitted sender) Received: from [209.85.218.15] (HELO mail-bw0-f15.google.com) (209.85.218.15) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2009 19:42:09 +0000 Received: by bwz8 with SMTP id 8so25651502bwz.14 for ; Thu, 08 Jan 2009 11:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=XxmwRGDCY7UvAHSi+UTwFG/mdkxufpon4bpt+JfZulA=; b=IFsWbPSFjvr8bUJ7JrCQWNP6P8EHKgIa5O2iYj78HsYH9yqlzOkgRN9cDNH9+t8wQk gZSqwWp3HVFJJAReWzpcfC9v6PIy7mLwLdRSi39jLwX6tVHfqkSO3E9MI2FyswMZeWCp CWAlixlOwQMvseSRJu+DdQ27aJ+6aFNtVmmC0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=UPJUo5nhsRXodYTlZliZ7NVRyiLGMurVVtgLTHheQigZjzHEW6LuxPR02vwJkK395o yNOKY7+yJWy/mbXOStXssmyZ7Xd3FOw7S6K9BMgqarA3ofMZA2vwbwBBTxPmd7/JhVXM gweZ3lNmSjkoRQ4clwY+G2glF4WfWtl/0wfbA= Received: by 10.223.108.140 with SMTP id f12mr13756835fap.23.1231443705368; Thu, 08 Jan 2009 11:41:45 -0800 (PST) Received: by 10.223.120.3 with HTTP; Thu, 8 Jan 2009 11:41:45 -0800 (PST) Message-ID: <5380c69c0901081141p7b7f04d6maaff427411a8b4a6@mail.gmail.com> Date: Thu, 8 Jan 2009 20:41:45 +0100 From: "Claus Ibsen" To: camel-user@activemq.apache.org Subject: Re: Two questions: Stopping Camel and intercept before retry In-Reply-To: <21359117.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <21323127.post@talk.nabble.com> <4964432F.6050608@gmail.com> <5380c69c0901070252j2dfa2037tb02170334e04f9aa@mail.gmail.com> <5380c69c0901070843t4042bc16m7a0ece33195d86c4@mail.gmail.com> <21343817.post@talk.nabble.com> <5380c69c0901072125s6a7cc2d6g1efa31fe2145e422@mail.gmail.com> <21359117.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Jan 8, 2009 at 8:25 PM, harinair wrote: > > Claus: > > Thanks once again - I will do that. So that my interceptor is called only > once. > > Do you think it is a good idea to add this shutdown hook to the Main.main()? > In that I can remove my main() and the HangUpInterceptor. I can also make > that modification and submit. I think I have to sign the Apache Development > agreement or something? I will do that too. Yeah that is a nice place then its added at the beginning. See contributing http://activemq.apache.org/camel/contributing.html For submitting patches you dont need to sign the Apache CLA. Just remember to tick [x] in the grant ASF license when you attach a file to the ticket in JIRA. > > PS: I just noticed that the DEAD LETTER CHANNEL Wiki page seems to be > updated incorrectly. The new section you added is missing. Take a look. The static wiki pages takes some time before they are updated with the latest changes. PS: I am about to commit the onRedelivery feature in Camel 1.5.1 so it will be there out-of-the-box in the future release. > > Regards, > Hari Gangadharan > > > > Claus Ibsen-2 wrote: >> >> On Thu, Jan 8, 2009 at 1:53 AM, harinair wrote: >>> >>> Thanks a lot for the quick reply. >>> >>> I read your wiki writeup. Doesn't that make the interceptor run on all >>> the >>> subsequent pipelines if the Redelivered flag is not set to null by the >>> Interceptor? Is it OK to set the Redelivered Flag to null? Is that used >>> by >>> any other Camel components? >> Hi yeah I think you can clear the flag after you have done your custom >> processing, so it wont intercept it again. >> Camel should readd if it fails on the next attempt of redelivery. Good >> idea. >> >> No the flag is for end users to inspect, to notice if the exchange is >> being redeliveried. It's not used by other components. >> >> But I will see if I can create a better solution with a nicer >> configuration using DLC directly or onException, >> >> >>> >>> >>> For stopping Camel gracefully - I did something like this: >>> in my main(): >>> >>> >>>> org.apache.camel.spring.Main main = new >>>> org.apache.camel.spring.Main(); >>>> HangUpInterceptor interceptor = new HangUpInterceptor(main); >>>> Runtime.getRuntime().addShutdownHook(interceptor); >>>> main.start(); >>>> >>> >>> I also added a HangUpInterceptor: >>> >>> >>>> public class HangUpInterceptor extends Thread { >>>> >>>> Log log = LogFactory.getLog(this.getClass()); >>>> Main main; >>>> >>>> public HangUpInterceptor(Main main) { >>>> this.main = main; >>>> } >>>> >>>> public void run() { >>>> log.info("Recieved hang up - stopping Camel."); >>>> try { >>>> main.stop(); >>>> } catch (Exception ex) { >>>> log.warn("Failure stopping Camel", ex); >>>> } >>>> } >>>> } >>>> >>> >>> Now the process goes down gracefully on a kill -HUP. >> Yeah I thought of a shutdown hook to stop Camel. That should do the trick. >> >> >>> >>> Regards, >>> Hari Gangadharan >>> >>> >>> >>> Claus Ibsen-2 wrote: >>>> >>>> Hi >>>> >>>> I have created a ticket to enhanced this in Camel >>>> https://issues.apache.org/activemq/browse/CAMEL-1234 >>>> >>>> I have also added a wiki sample with a solution. Albeit not as good as >>>> it will kick in even if the redelivery was a success as long the >>>> redelivery flag is set >>>> But it give the basic idea how to do it. >>>> http://cwiki.apache.org/confluence/display/CAMEL/Dead+Letter+Channel >>>> >>>> >>>> >>>> On Wed, Jan 7, 2009 at 11:52 AM, Claus Ibsen >>>> wrote: >>>>> Hi >>>>> >>>>> I am working on some samples now for this. Will get back later. >>>>> >>>>> >>>>> On Wed, Jan 7, 2009 at 6:52 AM, Willem Jiang >>>>> wrote: >>>>>> Hi, >>>>>> >>>>>> Please see my comment in the mail. >>>>>> >>>>>> harinair wrote: >>>>>>> Hi All: >>>>>>> >>>>>>> Thanks a lot for all the help I have received. We are nearing a >>>>>>> production >>>>>>> implementation of a Camel based messaging system! It was a great >>>>>>> experience, >>>>>>> I learned a lot and we saved a lot of time since I used Camel. >>>>>>> >>>>>>> I now have two questions: >>>>>>> >>>>>>> 1. I use org.apache.camel.spring.Main to start my standalone Camel >>>>>>> context. >>>>>>> Now how do I stop it? Till now I was killing it. Can I kill it? I >>>>>>> guess >>>>>>> it >>>>>>> may not be the right way since I have a feeling that the messages in >>>>>>> the >>>>>>> pipeline (especially the ones that are in Retry processing) is lost. >>>>>>> >>>>>> >>>>>> If you take a look at the org.apache.camel.spring.Main, you will find >>>>>> this Main class has start and stop methods, so you could write your >>>>>> own >>>>>> manager class which is based on the Spring main. >>>>>> >>>>>> >>>>>>> 2. I really need to get access to the Message between each retry. I >>>>>>> use >>>>>>> recipientList to forward message to different endpoints based on a >>>>>>> header. I >>>>>>> have also retry rules which make the Endpoint retry a specific number >>>>>>> of >>>>>>> times. In many cases I may have to get control and make some header >>>>>>> modification of the message before each retry. I could not find any >>>>>>> good >>>>>>> docs on that. Is there any Strategy implementation I can use that can >>>>>>> get >>>>>>> control of the exchange before each retry? If that is not there >>>>>>> wouldn't it >>>>>>> be a good idea to provide a way to intercept messages before each >>>>>>> retry? >>>>>>> >>>>>> I think you need get to know some detail of the camel >>>>>> ErrorHandler[1][2] >>>>>> first, then you could write your own DeadLetterChannel[3][4] to add >>>>>> you >>>>>> what you need to control the exchange before retrying. >>>>>> >>>>>>> Thanks in advance, >>>>>>> Hari Gangadharan >>>>>>> >>>>>> >>>>>> [1]http://activemq.apache.org/camel/error-handling-in-camel.html >>>>>> [2]http://activemq.apache.org/camel/error-handler.html >>>>>> [3]http://activemq.apache.org/camel/dead-letter-channel.html >>>>>> [4]http://svn.apache.org/repos/asf/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java >>>>>> >>>>>> Willem >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> >>>>> /Claus Ibsen >>>>> Apache Camel Committer >>>>> Blog: http://davsclaus.blogspot.com/ >>>>> >>>> >>>> >>>> >>>> -- >>>> >>>> /Claus Ibsen >>>> Apache Camel Committer >>>> Blog: http://davsclaus.blogspot.com/ >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/Two-questions%3A-Stopping-Camel-and-intercept-before-retry-tp21323127s22882p21343817.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >>> >>> >> >> >> >> -- >> >> /Claus Ibsen >> Apache Camel Committer >> Blog: http://davsclaus.blogspot.com/ >> >> > > -- > View this message in context: http://www.nabble.com/Two-questions%3A-Stopping-Camel-and-intercept-before-retry-tp21323127s22882p21359117.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- /Claus Ibsen Apache Camel Committer Blog: http://davsclaus.blogspot.com/