Grokbase Groups Camel users July 2014
FAQ
I think there is a serious issue when evaluatiog Bean language expression. it
seems like attachments are not copied from the resulting exchage.
very simple case: invoke a methode where you add an attachment to the
exchange, when the evaluation is ending the value of the exchange will be
null.
I debuged in camel source code, the method process Line n:174 did not copie
the attachment, below the source code:
-------------------------------
// copy the original exchange to avoid side effects on it
                 Exchange resultExchange = exchange.copy();
                 // remove any existing exception in case we do OGNL on the
exception
                 resultExchange.setException(null);

                 // force to use InOut to retrieve the result on the OUT
message
                 resultExchange.setPattern(ExchangePattern.InOut);
                 processor.process(resultExchange);
                 result = resultExchange.getOut().getBody();

                 // propagate properties and headers from result
                 if (resultExchange.hasProperties()) {

exchange.getProperties().putAll(resultExchange.getProperties());
                 }
                 if (resultExchange.getOut().hasHeaders()) {

exchange.getIn().getHeaders().putAll(resultExchange.getOut().getHeaders());
                 }

                 // propagate exceptions
                 if (resultExchange.getException() != null) {
                     exchange.setException(resultExchange.getException());
                 }
-------------------------------------------------------------------------
can you please approve the issue.



--
View this message in context: http://camel.465427.n5.nabble.com/Attachments-are-Lost-using-Bean-Language-tp5753283.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Search Discussions

  • Willem Jiang at Jul 3, 2014 at 2:18 pm
    Yeah, we need to copy the attachments back.
    I just filled a JIRA[1] for it.

    [1]https://issues.apache.org/jira/browse/CAMEL-7575

    --
    Willem Jiang

    Red Hat, Inc.
    Web: http://www.redhat.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.iteye.com (Chinese)
    Twitter: willemjiang
    Weibo: 姜宁willem


    On July 3, 2014 at 8:00:24 PM, sabri.bousselmi (infosabri@yahoo.fr) wrote:
    I think there is a serious issue when evaluatiog Bean language expression. it
    seems like attachments are not copied from the resulting exchage.
    very simple case: invoke a methode where you add an attachment to the
    exchange, when the evaluation is ending the value of the exchange will be
    null.
    I debuged in camel source code, the method process Line n:174 did not copie
    the attachment, below the source code:
    -------------------------------
    // copy the original exchange to avoid side effects on it
    Exchange resultExchange = exchange.copy();
    // remove any existing exception in case we do OGNL on the
    exception
    resultExchange.setException(null);

    // force to use InOut to retrieve the result on the OUT
    message
    resultExchange.setPattern(ExchangePattern.InOut);
    processor.process(resultExchange);
    result = resultExchange.getOut().getBody();

    // propagate properties and headers from result
    if (resultExchange.hasProperties()) {

    exchange.getProperties().putAll(resultExchange.getProperties());
    }
    if (resultExchange.getOut().hasHeaders()) {

    exchange.getIn().getHeaders().putAll(resultExchange.getOut().getHeaders());
    }

    // propagate exceptions
    if (resultExchange.getException() != null) {
    exchange.setException(resultExchange.getException());
    }
    -------------------------------------------------------------------------
    can you please approve the issue.



    --
    View this message in context: http://camel.465427.n5.nabble.com/Attachments-are-Lost-using-Bean-Language-tp5753283.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Willem Jiang at Jul 4, 2014 at 3:29 am
    After did some patch work, I have to take my world back. I don’t think we need to copy the attachment back in the InvokeProcessor.

    For BeanExpression, we are not supposed to modify the exchange or the message in the evaluation processor, camel just want to know the result of the evaluation.

    If you want to change the message attachment header, you can use bean process to do that kind of job. I just commit an unit test[1] to show how to set the attachment in the bean processor.

    [1]http://git-wip-us.apache.org/repos/asf/camel/commit/a749cefe
    --
    Willem Jiang

    Red Hat, Inc.
    Web: http://www.redhat.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.iteye.com (Chinese)
    Twitter: willemjiang
    Weibo: 姜宁willem


    On July 3, 2014 at 10:18:08 PM, Willem Jiang (willem.jiang@gmail.com) wrote:
    Yeah, we need to copy the attachments back.
    I just filled a JIRA[1] for it.

    [1]https://issues.apache.org/jira/browse/CAMEL-7575

    --
    Willem Jiang

    Red Hat, Inc.
    Web: http://www.redhat.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.iteye.com (Chinese)
    Twitter: willemjiang
    Weibo: 姜宁willem


    On July 3, 2014 at 8:00:24 PM, sabri.bousselmi (infosabri@yahoo.fr) wrote:
    I think there is a serious issue when evaluatiog Bean language expression. it
    seems like attachments are not copied from the resulting exchage.
    very simple case: invoke a methode where you add an attachment to the
    exchange, when the evaluation is ending the value of the exchange will be
    null.
    I debuged in camel source code, the method process Line n:174 did not copie
    the attachment, below the source code:
    -------------------------------
    // copy the original exchange to avoid side effects on it
    Exchange resultExchange = exchange.copy();
    // remove any existing exception in case we do OGNL on the
    exception
    resultExchange.setException(null);

    // force to use InOut to retrieve the result on the OUT
    message
    resultExchange.setPattern(ExchangePattern.InOut);
    processor.process(resultExchange);
    result = resultExchange.getOut().getBody();

    // propagate properties and headers from result
    if (resultExchange.hasProperties()) {

    exchange.getProperties().putAll(resultExchange.getProperties());
    }
    if (resultExchange.getOut().hasHeaders()) {

    exchange.getIn().getHeaders().putAll(resultExchange.getOut().getHeaders());
    }

    // propagate exceptions
    if (resultExchange.getException() != null) {
    exchange.setException(resultExchange.getException());
    }
    -------------------------------------------------------------------------
    can you please approve the issue.



    --
    View this message in context: http://camel.465427.n5.nabble.com/Attachments-are-Lost-using-Bean-Language-tp5753283.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Claus Ibsen at Jul 4, 2014 at 7:36 am
    Hi

    Yes Willem is correct. If you want to adjust the message, then you
    need to use the message translate eip.

    Invoking an expression/predicate/language etc should not affect the message.

    On Fri, Jul 4, 2014 at 5:29 AM, Willem Jiang wrote:
    After did some patch work, I have to take my world back. I don’t think we need to copy the attachment back in the InvokeProcessor.

    For BeanExpression, we are not supposed to modify the exchange or the message in the evaluation processor, camel just want to know the result of the evaluation.

    If you want to change the message attachment header, you can use bean process to do that kind of job. I just commit an unit test[1] to show how to set the attachment in the bean processor.

    [1]http://git-wip-us.apache.org/repos/asf/camel/commit/a749cefe
    --
    Willem Jiang

    Red Hat, Inc.
    Web: http://www.redhat.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.iteye.com (Chinese)
    Twitter: willemjiang
    Weibo: 姜宁willem


    On July 3, 2014 at 10:18:08 PM, Willem Jiang (willem.jiang@gmail.com) wrote:
    Yeah, we need to copy the attachments back.
    I just filled a JIRA[1] for it.

    [1]https://issues.apache.org/jira/browse/CAMEL-7575

    --
    Willem Jiang

    Red Hat, Inc.
    Web: http://www.redhat.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.iteye.com (Chinese)
    Twitter: willemjiang
    Weibo: 姜宁willem


    On July 3, 2014 at 8:00:24 PM, sabri.bousselmi (infosabri@yahoo.fr) wrote:
    I think there is a serious issue when evaluatiog Bean language expression. it
    seems like attachments are not copied from the resulting exchage.
    very simple case: invoke a methode where you add an attachment to the
    exchange, when the evaluation is ending the value of the exchange will be
    null.
    I debuged in camel source code, the method process Line n:174 did not copie
    the attachment, below the source code:
    -------------------------------
    // copy the original exchange to avoid side effects on it
    Exchange resultExchange = exchange.copy();
    // remove any existing exception in case we do OGNL on the
    exception
    resultExchange.setException(null);

    // force to use InOut to retrieve the result on the OUT
    message
    resultExchange.setPattern(ExchangePattern.InOut);
    processor.process(resultExchange);
    result = resultExchange.getOut().getBody();

    // propagate properties and headers from result
    if (resultExchange.hasProperties()) {

    exchange.getProperties().putAll(resultExchange.getProperties());
    }
    if (resultExchange.getOut().hasHeaders()) {

    exchange.getIn().getHeaders().putAll(resultExchange.getOut().getHeaders());
    }

    // propagate exceptions
    if (resultExchange.getException() != null) {
    exchange.setException(resultExchange.getException());
    }
    -------------------------------------------------------------------------
    can you please approve the issue.



    --
    View this message in context: http://camel.465427.n5.nabble.com/Attachments-are-Lost-using-Bean-Language-tp5753283.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
    hawtio: http://hawt.io/
    fabric8: http://fabric8.io/
  • Sabri.bousselmi at Jul 4, 2014 at 7:43 am
    I'm not Agree with you, otherwise attachments before evaluation will also be
    lost.
    I don't undersatand why for BeanExpression we cannot do both
    modification(attach) + evaluation if is it possible. Bean process is not a
    solution for me i'm following a specific pattern :(




    --
    View this message in context: http://camel.465427.n5.nabble.com/Attachments-are-Lost-using-Bean-Language-tp5753283p5753325.html
    Sent from the Camel - Users mailing list archive at Nabble.com.
  • Willem Jiang at Jul 4, 2014 at 12:19 pm
    Camel just copy a new exchange for bean expression to use, the attachment in the old exchange won’t be lost.

    We don’t encourage the people to modify the exchange when doing the evaluation, otherwise the result will be changed in the next expression evaluation.

    --
    Willem Jiang

    Red Hat, Inc.
    Web: http://www.redhat.com
    Blog: http://willemjiang.blogspot.com (English)
    http://jnn.iteye.com (Chinese)
    Twitter: willemjiang
    Weibo: 姜宁willem


    On July 4, 2014 at 3:43:01 PM, sabri.bousselmi (infosabri@yahoo.fr) wrote:
    I'm not Agree with you, otherwise attachments before evaluation will also be
    lost.
    I don't undersatand why for BeanExpression we cannot do both
    modification(attach) + evaluation if is it possible. Bean process is not a
    solution for me i'm following a specific pattern :(




    --
    View this message in context: http://camel.465427.n5.nabble.com/Attachments-are-Lost-using-Bean-Language-tp5753283p5753325.html
    Sent from the Camel - Users mailing list archive at Nabble.com.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedJul 3, '14 at 12:00p
activeJul 4, '14 at 12:19p
posts6
users3
websitecamel.apache.org

People

Translate

site design / logo © 2021 Grokbase