You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dtabwhite <da...@mindreef.com> on 2008/03/07 20:22:34 UTC

How to get the "whole" Http exchange (i.e. request/response)

I'm sure I'm missing something obvious here...

I'm trying to use the jetty, http and/or jhc components to proxy/forward
incoming http requests to various target destinations.  Along the way, I'd
like to be able to "capture" the exchange where the incoming request is the
"in" message and the outgoing response is the "out" message.  It seems as
though the jetty component populates the in message with the request, but
after sending this to the http component the resulting exchange has the http
response as the in message.

Now I tried to follow the lengthy in/out/fault thread in this mailing list
as I think there are some points in there that I believe relate to my
confusion.  I can see from a certain point of view how an exchange flowing
out of the http component would have the results (i.e. response) in the "in"
message of the exchange for the next processor in the pipeline.  Still, it
does seem odd at first blush.

Should there be separate "outflow" processors?  For example, I'd like to be
able to "get at" the full exchange prior to the jetty component writing the
response.  If there is such a thing and I've simply missed it (quite
likely...), please clue me in.

Thanks,

Dave
--
-- 
View this message in context: http://www.nabble.com/How-to-get-the-%22whole%22-Http-exchange-%28i.e.-request-response%29-tp15903881s22882p15903881.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to get the "whole" Http exchange (i.e. request/response)

Posted by dtabwhite <da...@mindreef.com>.
Thanks, that certainly helps.  I didn't know about the setProperty method
from the DSL.

FWIW - I think I found another option by making use of:

Exchange.getUnitOfWork().addSynchronization(...)

from a Processor implementation and then I believe I have the full
request/response available in the Synchronization callback.

Dave
--


RomKal wrote:
> 
> 2008/3/7, dtabwhite <da...@mindreef.com>:
>>  Should there be separate "outflow" processors?  For example, I'd like to
>> be
>>  able to "get at" the full exchange prior to the jetty component writing
>> the
>>  response.  If there is such a thing and I've simply missed it (quite
>>  likely...), please clue me in.
> 
> I'm not sure if you are still interested in the answer, but let me
> give you 'a clue'.
> 
> If you want to have original request AND response just record the
> request somewhere (in a property) like:
> 
> from("jetty:http://localhost:1234/test")
> .convertBodyTo(String.class)
> .setProperty("originalIn", body())
> .to("http://foo:2345/bar")
> .process(new MyProcessorUsingOriginalInPropertyToAccessRequest());
> 
> Roman
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-the-%22whole%22-Http-exchange-%28i.e.-request-response%29-tp15903881s22882p16012629.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to get the "whole" Http exchange (i.e. request/response)

Posted by Roman Kalukiewicz <ro...@gmail.com>.
2008/3/7, dtabwhite <da...@mindreef.com>:
>  Should there be separate "outflow" processors?  For example, I'd like to be
>  able to "get at" the full exchange prior to the jetty component writing the
>  response.  If there is such a thing and I've simply missed it (quite
>  likely...), please clue me in.

I'm not sure if you are still interested in the answer, but let me
give you 'a clue'.

If you want to have original request AND response just record the
request somewhere (in a property) like:

from("jetty:http://localhost:1234/test")
.convertBodyTo(String.class)
.setProperty("originalIn", body())
.to("http://foo:2345/bar")
.process(new MyProcessorUsingOriginalInPropertyToAccessRequest());

Roman