You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Babak Vahdat <ba...@swissonline.ch> on 2012/06/04 15:25:25 UTC

About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Hi

By the following ticket there is a conceptual Question (at least of mine)
about how a Producer should CORRECTLY behave when the Exchange is NOT out
capable:

https://issues.apache.org/jira/browse/CAMEL-5234

Any thought would be much appreciated.

Babak


--
View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi Bilgin,

Thanks a lot for your feedback!

Makes me happy to see others arguing the same thing as me :-)

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714059.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Bilgin Ibryam <bi...@gmail.com>.
Hi Babak,

I think your example makes perfect sense and if the exchange pattern
is InOnly one should not be able to set the body of the OUT.

If the API is less friendly, then the users will be able to figure out
easily what Christian said "the component should check the MEP and put
the response into the out message if the MEP is "out capable" or
replace the in message if not "

Bilgin

>
> Again my previous stupid example:
>
>  Exchange exchange = new DefaultExchange(new DefaultCamelContext());
>  exchange.setPattern(ExchangePattern.InOnly);     <== InOnly is already the
> default but just to make my intention clear
>  exchange.getOut().setBody("Camel");
>
> Just because of the "too friendly" behaviour of the API we did set the OUT
> of an Exchange to something != null ALTHOUGH the exchange pattern was
> InOnly!
>
> Babak
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714021.html
> Sent from the Camel Development mailing list archive at Nabble.com.

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi Raúl,

Thanks for sharing your thoughts:

> In fact, (in my mind) it should be strictly illegal for an InOnly consumer 
> to attempt to access the OUT message from an Exchange, even though this is 
> not enforced by the Camel APIs right now AFAIK.

I assume with "InOnly consumer" you did actually mean "InOnly producer". And
you exactly did point out where it currently hurts me by the API :-( As I
simply do not get the point

Again my previous stupid example:

 Exchange exchange = new DefaultExchange(new DefaultCamelContext());
 exchange.setPattern(ExchangePattern.InOnly);     <== InOnly is already the
default but just to make my intention clear
 exchange.getOut().setBody("Camel"); 

Just because of the "too friendly" behaviour of the API we did set the OUT
of an Exchange to something != null ALTHOUGH the exchange pattern was
InOnly!

Babak 

--
View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714021.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Raul Kripalani <ra...@fusesource.com>.
Hi,

My understanding is that in an InOnly exchange, what counts is the status
of the Exchange (completed or failed) and the Unit Of Work rather than the
OUT message.

When the Exchange completes and the processor stack unwinds, InOnly
consumer can react differently depending on whether the outcome was
successful or not (i.e. rollback a transaction - we see this in camel-jms,
or move a file to a "failed" directory - File component, etc.), i.e. if an
unhandled Exception is marked in the Exchange.

In fact, (in my mind) it should be strictly illegal for an InOnly consumer
to attempt to access the OUT message from an Exchange, even though this is
not enforced by the Camel APIs right now AFAIK.

Regards,

 *Raúl Kripalani*
Principal Consultant | FuseSource Corp.
raul@fusesource.com | fusesource.com <http://www.fusesource.com/>
skype: raul.fuse | twitter: @raulvk <http://twitter.com/raulvk>,
@fusenews<http://twitter.com/fusenews>
blog: F3 - Flashes From the
Field<http://blog.raulkr.net/?utm_source=fusesourceemail&utm_medium=email&utm_campaign=fusesourcemail>

<http://twitter.com/fusenews>

On 5 June 2012 11:11, Babak Vahdat <ba...@swissonline.ch> wrote:

> Thanks for that link but I've been already through that FAQ many many times
> which didn't help me as well! It seems I'm too dummy to understand this
> API.
>
> Yes I'm aware of the exchange.hasOut() semantics as well as the lazy
> instantiation of OUT through exchange.getOut()
>
> So again my question:
>
> - Do we currently have a Camel Producer behaving wrong concerning this
> question?
> - And still I think the fact that exchange.getOut() does lazily instantiate
> an OUT if OUT == null is an API flaw as this does bypass the semantics of
> the given exchange pattern of the exchange object. So that you can have an
> exchange with InOnly pattern having an OUT != null attached to it!
>
> Babak
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714015.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Babak Vahdat <ba...@swissonline.ch>.
Thanks for that link but I've been already through that FAQ many many times
which didn't help me as well! It seems I'm too dummy to understand this API.

Yes I'm aware of the exchange.hasOut() semantics as well as the lazy
instantiation of OUT through exchange.getOut()

So again my question:

- Do we currently have a Camel Producer behaving wrong concerning this
question?
- And still I think the fact that exchange.getOut() does lazily instantiate
an OUT if OUT == null is an API flaw as this does bypass the semantics of
the given exchange pattern of the exchange object. So that you can have an
exchange with InOnly pattern having an OUT != null attached to it!

Babak


--
View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714015.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 5, 2012 at 11:38 AM, Babak Vahdat
<ba...@swissonline.ch> wrote:
> Hi
>
> Then does it mean that camel-restlet Producer should be changed as well? I
> also looked into another two brand new components as well:
>
> camel-mongodb
> camel-hbase
>
> which do behave like camel-restlet as well, that's they don't take the
> exchange pattern into the account.
>
> In this context what I also think is an API flaw is that the following works
> perfectly:
>
>  Exchange exchange = new DefaultExchange(new DefaultCamelContext());
>  exchange.getOut().setBody("Camel");
>
> Maybe I'm missing something here but to my understanding as the default
> exchange pattern is InOnly one should not be able to set the body of the OUT
> message and the second line should blow up with some Not_Allowed unchecked
> exception.
>
> All in one I'm pretty confused with all this and would appreciate any
> clarifications.
>

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



> Babak
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714007.html
> Sent from the Camel Development mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

Then does it mean that camel-restlet Producer should be changed as well? I
also looked into another two brand new components as well:

camel-mongodb
camel-hbase

which do behave like camel-restlet as well, that's they don't take the
exchange pattern into the account.

In this context what I also think is an API flaw is that the following works
perfectly:

 Exchange exchange = new DefaultExchange(new DefaultCamelContext());
 exchange.getOut().setBody("Camel");

Maybe I'm missing something here but to my understanding as the default
exchange pattern is InOnly one should not be able to set the body of the OUT
message and the second line should blow up with some Not_Allowed unchecked
exception.

All in one I'm pretty confused with all this and would appreciate any
clarifications.

Babak


--
View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714007.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Christian Müller <ch...@gmail.com>.
My understanding is:
If a component provides integration for e.g. spring-ws and execute a
request which will receive a respone, this component should check the MEP
and put the response into the out message if the MEP is "out capable" or
replace the in message if not (and also the headers and attachments of
course).

Best,
Christian

On Mon, Jun 4, 2012 at 3:25 PM, Babak Vahdat <ba...@swissonline.ch>wrote:

> Hi
>
> By the following ticket there is a conceptual Question (at least of mine)
> about how a Producer should CORRECTLY behave when the Exchange is NOT out
> capable:
>
> https://issues.apache.org/jira/browse/CAMEL-5234
>
> Any thought would be much appreciated.
>
> Babak
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>

Re: About what to do with the Response retrieved through a Producer, when the Exchange is NOT out capable?

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

Before applying the fix into SVN, I attached a potential patch to the JIRA
(CAMEL-5234) for the review of volunteers (including a unit-test verifying
the change).

So please fell free to comment on the patch. The intention is to make sure
that we all have got the same understanding about the expected behaviour.
:-)

Babak


Babak Vahdat wrote
> 
> Hi
> 
> By the following ticket there is a conceptual Question (at least of mine)
> about how a Producer should CORRECTLY behave when the Exchange is NOT out
> capable:
> 
> https://issues.apache.org/jira/browse/CAMEL-5234
> 
> Any thought would be much appreciated.
> 
> Babak
> 

--
View this message in context: http://camel.465427.n5.nabble.com/About-what-to-do-with-the-Response-retrieved-through-a-Producer-when-the-Exchange-is-NOT-out-capable-tp5713946p5714196.html
Sent from the Camel Development mailing list archive at Nabble.com.