Apache Camel: Response is get lost when reached explicitly on route -
i getting strange situation @ code below routes request google , returns response.
it works when activate line commented out "//activating line causes empty response on browser" print out returned response http endpoint (google), response disappear, nothing displayed on browser. thought might related input stream of http response can consumed once , activated stream caching on context nothing changed.
apache camel version 2.11.0
any suggestions appreciated, in advance.
public class googlecaller { public static void main(string[] args) throws exception { camelcontext context = new defaultcamelcontext(); context.addroutes(new routebuilder() { public void configure() { from("jetty:http://0.0.0.0:8081/myapp/") .to("jetty://http://www.google.com?bridgeendpoint=true&throwexceptiononfailure=false") .process(new processor() { public void process(exchange exchange) throws exception { system.out.println("response received google, streamcaching = " + exchange.getcontext().isstreamcaching()); system.out.println("----------------------------------------------in message--------------------------------------------------------------"); system.out.println(exchange.getin().getbody(string.class)); system.out.println("----------------------------------------------out message--------------------------------------------------------------"); //system.out.println(exchange.getout().getbody(string.class)); //activating line causes empty response on browser } }); } }); context.settracing(true); context.setstreamcaching(true); context.start(); } }
as use custom processor process message, should keep in mind in message of exchange has response message google, if using exchange.getout(), camel create new empty out message , treat response message.
because don't set out message body in processor, makes sense empty response in browser.