camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: NotifyBuilder "intercept" support
Date Thu, 18 Feb 2010 07:37:52 GMT

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:


> Thanks,
> /Johan
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

Claus Ibsen
Apache Camel Committer

Author of Camel in Action:
Open Source Integration:

View raw message