camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: .filter().method(...) does not modify Exchange
Date Thu, 15 Dec 2011 08:57:41 GMT
Hi,

The Predicate does not suppose to change the message.
And the bean expression only affect to out message body.

You can change the message header and body in processor or bean method.

On Thu Dec 15 15:25:27 2011, rhowlett wrote:
> I wanted to do this:
>
>
> from("direct:start")
>    .filter().method("beanRefName", "methodName")
>      .to("log:test?showAll=true&multiline=true")
> .end();
>
>
> The bean class would be pretty simple:
>
>
> public class BeanName {
>
>    public boolean methodName(@Body String body, Exchange exchange,
> @OutHeaders Map<String, Object>  outHeaders) {
>      // some logic
>      outHeaders.put("someKey", "someValue");
>      return someBooleanValue;
>    }
>
> }
>
>
> However, the out Message headers are never set and don't show up on the log
> output.
>
> I had a look at the Bean Processor and I can see that the out message on the
> referenced exchange has the new headers, but the in message's headers are
> actually the ones being copied over.
>
> Altering the injected Exchange object doesn't work either, nor does using
> any kind of ExpressionDefinition with BeanLanguage.bean(...).
>
> A basic beanRef works fine (the out headers are set on the exchange):
>
>
> from("direct:start")
>    .beanRef("beanRefName", "methodName")
>    .to("log:test?showAll=true&multiline=true");
>
>
> I wanted to use the bean like a Predicate and alter the injected
> Exchange/Headers. Anyone have any ideas to do this?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/filter-method-does-not-modify-Exchange-tp5076735p5076735.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Mime
View raw message