I am new for Apache Camel concept. I have tried to write sample code using with apache camel API's and I am getting the following exception when try to run the code.
Can anyone help me to solve this issue?
Here's the sample code and an exception as well,
Sample Code :
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start")
.setHeader(Exchange.HTTP_URI,simple("`http://sample-host:8080/demo/get`"))
.to("http://emptyhost");
}
});
context.start();
ProducerTemplate template = context.createProducerTemplate();
System.out.println(template.requestBodyAndHeaders("direct:start", null, null,String.class));
Exception :
Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at:
>>> To[`http://sample-host:8080/demo/get`] <<<
in route: Route(route1)
[[From[direct:start]] -> [`To[http://sample-host:8`…
because of
Failed to resolve endpoint: `http://sample-host:8080/demo/get`
due to:
No component found with scheme: http
A Camel route is where the integration flow is defined. For example to integrate two systems then a Camel route can be coded to specify how these systems are integrated. An example could be to take files from a FTP server and send to a ActiveMQ messaging system.
routeId() are for identifying routes. By adding ids you can in your tests use adviceWith() to mock or inject or remove parts of your route to perform automated tests without having access to backend systems.
The RouteBuilder is a base class which is derived from to create routing rules using the DSL. Instances of RouteBuilder are then added to the CamelContext .
Dependency libraries were missing. So i have added those libraries and solved my issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With