Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 43242 invoked from network); 18 Feb 2010 07:38:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Feb 2010 07:38:44 -0000 Received: (qmail 66973 invoked by uid 500); 18 Feb 2010 07:38:43 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 66907 invoked by uid 500); 18 Feb 2010 07:38:43 -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 66896 invoked by uid 99); 18 Feb 2010 07:38:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2010 07:38:43 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 72.14.220.152 as permitted sender) Received: from [72.14.220.152] (HELO fg-out-1718.google.com) (72.14.220.152) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2010 07:38:34 +0000 Received: by fg-out-1718.google.com with SMTP id e21so199996fga.2 for ; Wed, 17 Feb 2010 23:38:12 -0800 (PST) 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; bh=w7ON4Ocm8Uc75DA7JBeOeZguTT/Hc9NakoHPtvGKLwA=; b=cBOitHhx3Ij/gXYyQHFl+rI8HlJborJv4qAQUMsOBJY/trRqvDhIpMgqvDq2GIKsjC pB01PSCT/T4mF0OwU9iK5zJb/raWafYRFRis9oYPJywZBvt84guC7D2XFn814aLVQ+ka 0pt7FIoI3hI3B7K4KbMCJB4xLldByCBjBMCAI= 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; b=mt+piw2Ay379plc4+Q3CXp9sxbIpGpGylhB/fVzr00LOAVS43P9u+MwjxWOajroLil TiaDQ9I8bdBlxjqFzAD/R331vqA7yx8I+Og343eWDQ5M3G74MgSvLiOKHqAcnN+cCttR RbLiMOAUsplzi1Sstup3NsSJwXmO3DDY0L+4k= MIME-Version: 1.0 Received: by 10.204.29.17 with SMTP id o17mr1992708bkc.184.1266478692147; Wed, 17 Feb 2010 23:38:12 -0800 (PST) In-Reply-To: <27608556.post@talk.nabble.com> References: <27608556.post@talk.nabble.com> From: Claus Ibsen Date: Thu, 18 Feb 2010 08:37:52 +0100 Message-ID: <5380c69c1002172337q5dffebdft2173424f2fd27145@mail.gmail.com> Subject: Re: NotifyBuilder "intercept" support To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Hi On Tue, Feb 16, 2010 at 2:53 PM, Johan Haleby wrote: > > Hi, > > I've just upgraded to Camel 2.2 since I'd like to use the new NotifyBuilder > in my test class. How ever it doesn't really seem to fit my use case 100%. > What I'm missing is interception or "side-effect" support. In my test case > I'd like to extract an ID that's located in the message body and store it > away temporarily (for synchronization purposes). This means that I don't > need any matching, I just want to perform some operation for each message > that arrives to an endpoint. As a work-around I've created a Predicate that > does exactly this which is defined by: > > notifyBuilder.from(outboundEnpoint).filter(extractId()).create(); // > extractId returns the Predicate impl > > I figure it would have been better to add e.g. a "filter(Interceptor > interceptor)" method to NotifyBuilder which contains a method like "void > intercept(Exchange exchange)". > The problem is the notify builder is based on the EventNotifier which *only* have a starting and ending event for a given Exchange. So if you want to intercept every step the Exchange does, then that is not possible. However in the future I would like to make that more easily possible. We got the foundation in place in the 2.0 line. There is a org.apache.camel.Channel concept, which acts as a delegate between each node an Exchange undergoes. The Channel is currently a bit too static how it delegates, but in the future we will make that much more dynamic so you can add interceptors and whatnot more easily on the fly, without the need for a RouteBuilder. > Also I've noticed that the "extractId" predicate instance is called twice > for each message. I suppose that's because it gets called once for > "ExchangeCreatedEvent" and once for the "ExchangeCompletedEvent". So I would > also like tge ability to e.g. only filter "ExchangeCompletedEvent" events. > In my case something like: > > notifyBuilder.from(outboundEnpoint).filter(extractIdInterceptor()).onExchangeCompletedEvent().create(); > > Or is there another way to achieve what I'm looking for? > Maybe something like should do what you want: notifyBuilder.from(outboundEnpoint).whenAnyReceivedMatches(extractId()).create(); > Thanks, > /Johan > -- > View this message in context: http://old.nabble.com/NotifyBuilder-%22intercept%22-support-tp27608556p27608556.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus