Reputation: 3
I have a route
'Server received: ' + exchange.getIn().getBody(String.class)
I want to send data to this socket using some java client . How can i do that?
Upvotes: 0
Views: 309
Reputation: 1140
'Server received: ' + exchange.getIn().getBody(String.class) is not a camel route, it is more a processor that print the body content. You need to define a CamelContext, add a route with a custom processor
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("direct:start")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
System.out.println("Server received: " + body);
}
})
}
});
ProducerTemplate template = context.createProducerTemplate();
context.start();
template.sendBody("direct:start", "Hello World");
Upvotes: 1