-
Notifications
You must be signed in to change notification settings - Fork 13
Quickstart
Giwi edited this page Nov 13, 2012
·
4 revisions
Please see this chapter.
Well this is the most complicated part, you have to follow this guide : http://incubator.apache.org/kafka/quickstart.html
That's all.
MainApp.java
package org.giwi.camel.kafka.test.KafkaTest;
import org.apache.camel.main.Main;
/**
* A Camel Application
*/
public class MainApp {
/**
* A main() so we can easily run these routing rules in our IDE
*/
public static void main(String... args) throws Exception {
Main main = new Main();
main.enableHangupSupport();
main.addRouteBuilder(new MyRouteBuilder());
main.run(args);
Thread.sleep(30000);
}
}
MyRouteBuilder.java
package org.giwi.camel.kafka.test.KafkaTest;
import org.apache.camel.builder.RouteBuilder;
/**
* A Camel Java DSL Router
*/
public class MyRouteBuilder extends RouteBuilder {
/**
* Let's configure the Camel routing rules using Java code...
*/
@Override
public void configure() {
from("timer://foo?fixedRate=true&period=5000")
.setBody(constant("hello from Giwi Softwares"))
.to("kafka:TOPIC-TEST?zkConnect=localhost:2181");
// Recieving
from("kafka:TOPIC-TEST?groupId=camelTest&zkConnect=localhost:2181").log("${body}");
}
}