You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by yirco <ne...@yahoo.com> on 2013/09/21 19:19:17 UTC

Must Processor check if Exchange has out message already?

Hi,

until now I haven't checked Exchange.hasOut() in Processor.process(Exchange)
and always used only Exchange.getIn(). However, I started using
BindingComponent which creates BindingEndpoint and this BindingEndpoint
calls delegate Processor with Exchange that has both in and out Messages
set. 

My question is if this behaviour of BindingEndpoint is correct or if
BindingEndpoint shall set only in Message and the out Message shall be null.

The code snippet is from the BindingEndpoint and the bold statement copies
the in Message into out Message. It is not clear to me why the statement is
there if createNextExchange(bindingExchange) before already takes care of
the message copying and sets the out Message to null.

Thank you.

    public void pipelineBindingProcessor(Processor bindingProcessor,
Exchange exchange, Processor delegateProcessor) throws Exception {
        // use same exchange - seems Pipeline does these days
        Exchange bindingExchange = exchange;
        bindingProcessor.process(bindingExchange);
        Exchange delegateExchange = createNextExchange(bindingExchange);
       * ExchangeHelper.copyResults(bindingExchange, delegateExchange);*
        delegateProcessor.process(delegateExchange);
    }

    protected Exchange createNextExchange(Exchange previousExchange) {
        Exchange answer = previousExchange;

        // now lets set the input of the next exchange to the output of the
        // previous message if it is not null
        if (answer.hasOut()) {
            answer.setIn(answer.getOut());
            answer.setOut(null);
        }
        return answer;
    }



--
View this message in context: http://camel.465427.n5.nabble.com/Must-Processor-check-if-Exchange-has-out-message-already-tp5739977.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Must Processor check if Exchange has out message already?

Posted by yirco <ne...@yahoo.com>.
OK, thank you.



--
View this message in context: http://camel.465427.n5.nabble.com/Must-Processor-check-if-Exchange-has-out-message-already-tp5739977p5740139.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Must Processor check if Exchange has out message already?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah well spotted I logged
https://issues.apache.org/jira/browse/CAMEL-6780

On Mon, Sep 23, 2013 at 6:02 PM, yirco <ne...@yahoo.com> wrote:
> Hi Claus,
>
> thank you. I actually read this page. I was not just sure if the framework
> should guarantee that the out message is always null when I receive exchange
> in my processor because it is not the case when the binding component is
> used.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Must-Processor-check-if-Exchange-has-out-message-already-tp5739977p5740073.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Must Processor check if Exchange has out message already?

Posted by yirco <ne...@yahoo.com>.
Hi Claus,

thank you. I actually read this page. I was not just sure if the framework
should guarantee that the out message is always null when I receive exchange
in my processor because it is not the case when the binding component is
used.



--
View this message in context: http://camel.465427.n5.nabble.com/Must-Processor-check-if-Exchange-has-out-message-already-tp5739977p5740073.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Must Processor check if Exchange has out message already?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this page
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

On Sat, Sep 21, 2013 at 7:19 PM, yirco <ne...@yahoo.com> wrote:
> Hi,
>
> until now I haven't checked Exchange.hasOut() in Processor.process(Exchange)
> and always used only Exchange.getIn(). However, I started using
> BindingComponent which creates BindingEndpoint and this BindingEndpoint
> calls delegate Processor with Exchange that has both in and out Messages
> set.
>
> My question is if this behaviour of BindingEndpoint is correct or if
> BindingEndpoint shall set only in Message and the out Message shall be null.
>
> The code snippet is from the BindingEndpoint and the bold statement copies
> the in Message into out Message. It is not clear to me why the statement is
> there if createNextExchange(bindingExchange) before already takes care of
> the message copying and sets the out Message to null.
>
> Thank you.
>
>     public void pipelineBindingProcessor(Processor bindingProcessor,
> Exchange exchange, Processor delegateProcessor) throws Exception {
>         // use same exchange - seems Pipeline does these days
>         Exchange bindingExchange = exchange;
>         bindingProcessor.process(bindingExchange);
>         Exchange delegateExchange = createNextExchange(bindingExchange);
>        * ExchangeHelper.copyResults(bindingExchange, delegateExchange);*
>         delegateProcessor.process(delegateExchange);
>     }
>
>     protected Exchange createNextExchange(Exchange previousExchange) {
>         Exchange answer = previousExchange;
>
>         // now lets set the input of the next exchange to the output of the
>         // previous message if it is not null
>         if (answer.hasOut()) {
>             answer.setIn(answer.getOut());
>             answer.setOut(null);
>         }
>         return answer;
>     }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Must-Processor-check-if-Exchange-has-out-message-already-tp5739977.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen