Search code examples
apache-camelcamel-http

http4 not setting HTTP_RESPONSE properties


I have a really simple route that GETs an URL and prints the content using Camel HTTP4 component:

from("timer://foo?fixedRate=true&delay=0&period=10000")
    .to("http4://www.google.com")
    .process(e -> System.out.println("Out body: " + e.getOut().getBody()));

Note that I'm using out.body because, as stated in Camel documentation:

Camel will store the HTTP response from the external server on the OUT body. All headers from the IN message will be copied to the OUT message, so headers are preserved during routing.

But I get null values from OUT (both body and headers). Everything is being filled only in the IN message.

Am I missing anything or is it a bug?


Solution

  • In Camel a route consists of nodes. Each node takes the Exchange. Exchange has an IN and OUT message. So in your case, node with http4 component took the Exchange, called google.com and wrote body and headers to OUT message. Next, node with your proccesor took the Exchange. Now IN message has the response from the previous node(http4), but you are printing OUT which is empty! So IN and OUT message are per node not per route!