My problem is, I have to pass exchange body value (which is set in previous route) into .to("rest:get ...") step. I'm trying something like in the code below, but class variable id is equal to null in the important step, even though I'm setting its value in a custom processor one step before. I've also tried using simple() function, which can evaluate into exchange body, but the problem is I don't have access to exchange in .to("rest:get ...") method, I can only access it inside processor.
How can I pass exchange body value into .to("rest:get ...") step?
public class SomeRoute extends RouteBuilder {
@ConfigProperty(name = "rest.external.host")
String host;
@ConfigProperty(name = "rest.external.endpoint")
String endpoint;
String id;
@Override
public void configure() throws Exception {
restConfiguration().host(host);
from("direct:routeEntry")
.log(LoggingLevel.INFO, log, body().toString())
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.removeHeader(Exchange.HTTP_PATH)
.removeHeaders("Camel*")
.process(exchange -> {
id = exchange.getIn().getBody().toString();
})
.to("rest:get:" + endpoint + "/" + id)
.convertBodyTo(String.class);
}
}