You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "sabri.bousselmi" <in...@yahoo.fr> on 2014/07/03 13:42:48 UTC

Attachments are Lost using Bean Language

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.

Re: Attachments are Lost using Bean Language

Posted by Willem Jiang <wi...@gmail.com>.
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.
>  


Re: Attachments are Lost using Bean Language

Posted by "sabri.bousselmi" <in...@yahoo.fr>.
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.

Re: Attachments are Lost using Bean Language

Posted by Claus Ibsen <cl...@gmail.com>.
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 <wi...@gmail.com> 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/

Re: Attachments are Lost using Bean Language

Posted by Willem Jiang <wi...@gmail.com>.
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.
> >
>  
>  


Re: Attachments are Lost using Bean Language

Posted by Willem Jiang <wi...@gmail.com>.
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.
>