I am new to Apache Camel and I wanted to integrate or merge results of 2 API GET Requests and route their responses to a 3rd API.
1st API - http://localhost:8080/students/Student1 (GET method Returns {"id":"1","name":xyz"})
2nd API - http://localhost:8081/students/Student1 (GET method Returns {"id":"1","subject":"maths"})
3rd API - http://localhost:8082/students/combine (GET method should produce
{"id":"1","subject":"maths","name":"xyz"}
What I actually want to do is hit the 3rd API with a GET request so that it can implicitly call API1 and API2 and return output as: {"id":"1","subject":"maths","name":"xyz"}
This is the code I have written.
CamelContext context = new DefaultCamelContext(); JacksonDataFormat jsonDataFormat = new JacksonDataFormat(Output.class);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("jetty:http://localhost:8080/students/Student1")
.to("direct:merge)
from("jetty:http://localhost:8081/students/Student1")
.to("direct:merge")
from("direct:merge")
.to("jetty:http://localhost:8082/students/combine")
}
});
context.start();
}
}