On Sat, Apr 18, 2009 at 10:25 AM, Roman Kalukiewicz
<[email protected]> wrote:
> Hello,
>
> Just a quick note here. People usually get confused by what happens in
> getOut() method. Sometimes people just want to check if out message
> simply exists and they call getOut(). What happens is out message
> being created that is not what usually happens with methods that
> conform to JavaBeans convention.
>
> Maybe we should try to fix it before 2.0 finally comes out? I've seen
> a lot of such errors already simply because Camel don't stick to
> convention. It is easy to avoid it by looking into javadoc or source,
> bu... who does it really before trying ;) ?

We could add boolean hasOut() as a method on the Exchange.
Then you can test whether an OUT has been set or not.

even though getOut(false) does exactly that. Returning null if no OUT exists.




>
> Romek
>
> 2009/4/18 Claus Ibsen <[email protected]>:
>> Hi
>>
>> Or just set the header on the IN body.
>>
>> So the rule of thumb with the pipeline is basically as Willem writes.
>> If OUT != null then use OUT otherwise use IN.
>>
>> So if you just need to alter/set a single header on the payload then
>> you can just do it on IN and it will keep all the other data.
>> If you set something on OUT then you are starting from scratch and
>> must copy/set all the values you want to keep.
>>
>>
>> On Sat, Apr 18, 2009 at 6:33 AM, Willem Jiang <[email protected]> wrote:
>>> Hi,
>>>
>>> Please keep in mind, if you are using pipeline message pattern,
>>> the pipeline processor will copy the in message to the in message of
>>> the next processor's exchange if there is no out message. But if you set the
>>> out
>>> message to the exchange, the pipeline processor will copy the out message
>>> into the in message of next processor's exchange.
>>> You may need to change the processor() like this
>>> ...
>>> process(new Processor() {
>>>     public void process(Exchange exchange) throws Exception {
>>>          ...
>>>          exchange.getOut().setHeader("foo", "bar")
>>>          exchange.getOut().setBody(exchange.getIn().getBody);
>>>         ...
>>>     }
>>> }).to("seda:next");
>>>
>>>
>>> Willem
>>>
>>> On Sat, Apr 18, 2009 at 4:35 AM, Joe Fernandez <
>>> [email protected]> wrote:
>>>
>>>>
>>>> Hello Camel Riders,
>>>>
>>>> I implemented a simple pipeline message pattern and ran across a situation
>>>> where I would lose the body of my inbound message as it got forwarded from
>>>> one processor to the next. In other words, the exchange.getIn().getBody()
>>>> method would return null. I finally narrowed it down to the
>>>> exchange.getOut().setHeader() method, which I have listed below. If I
>>>> comment out that line, the next processor can get the inbound body. Why
>>>> would setting a header in the outbound message affect the inbound message?
>>>> Am I doing something wrong?
>>>>
>>>> ...
>>>> process(new Processor() {
>>>>      public void process(Exchange exchange) throws Exception {
>>>>           ...
>>>>           exchange.getOut().setHeader("foo", "bar");
>>>>           ...
>>>>      }
>>>>   }).to("seda:next");
>>>>
>>>> Thanks,
>>>> Joe
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Payload-Gets-Nulled-Out-tp23105477p23105477.html
>>>> Sent from the Camel - Users (activemq) 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
>> Apache Camel Reference Card:
>> http://refcardz.dzone.com/refcardz/enterprise-integration
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Apache Camel Reference Card:
http://refcardz.dzone.com/refcardz/enterprise-integration

Reply via email to