Presentations
public class MyRouteBuilder extends RouteBuilder {
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");
}
}
static RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from(DIRECT_KAFKA_START).routeId("DirectToKafka")
.to("kafka:").log(HEADERS);
// Topic can be set in header as well.
from("direct:kafkaStartNoTopic").routeId("kafkaStartNoTopic")
.to("kafka:dummy")
.log(HEADERS);
// Use custom partitioner based on the key.
from(DIRECT_KAFKA_START_WITH_PARTITIONER).routeId("kafkaStartWithPartitioner")
.to("kafka:?partitioner=")
.log(HEADERS);
// Takes input from the command line.
from("stream:in").id("input").setHeader(KafkaConstants.PARTITION_KEY, simple("0"))
.setHeader(KafkaConstants.KEY, simple("1")).to(DIRECT_KAFKA_START);
}
};
}