Reputation: 9529
I've just discovered Camel and it seems to be exactly what I need.
I have several building blocks which know how to process specific input data, so I want to create a very simple GUI for users to select building blocks, just chaining them one after another (sort of like Fuse IDE, but not that fancy. Just a linear list of components is enough for me).
I can't find examples how to start a context feed simple POJOs in it one by one, waiting every time until the previous input message reaches the end of it's route, and then get another POJO on the opposite end.
Or write it to a database / serialize to a file.
Googling only brings up some examples with Spring, ActiveMQ, etc. I just need the simplest scenario but figure out which URIs to use etc.
PS: I'm able to run this simple example (the only dependencies are camel-core 2.13 and slf4j 1.7.7)
CamelContext context = new DefaultCamelContext();
// add our route to the CamelContext
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("file:src/data?noop=true").
choice().
when(xpath("/person/city = 'London'")).to("file:target/messages/uk").
otherwise().to("file:target/messages/others");
}
});
// start the route and let it do its work
System.out.println("Starting camel no maven");
context.start();
Thread.sleep(3000);
System.out.println("Done camel no maven");
// stop the CamelContext
context.stop();
Upvotes: 0
Views: 2306
Reputation: 17443
Take a look at CamelProxy. It allows you to send to a Camel endpoint.
OrderService service = new ProxyBuilder(context)
.endpoint("direct:order")
.build(OrderService.class);
OrderService is an interface which defines the methods you want to use to send:
public interface OrderService {
public String send(SomeBean message);
}
Sample route:
from("direct:order").to("bean:someProcessor");
Send a message to the route:
String reply = service.send(new SomeBean());
Here is a simple working example
Upvotes: 4