I am new to Apache camel. we are doing POC to develop kafka consumer using Camel. Below is the sample code.
context.addRoutes(new RouteBuilder(){
@Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from("kafka:{{consumer.topic}}?brokers={{kafka.host}}:{{kafka.port}}"
+ "&consumersCount={{consumer.consumersCount}}"
+ "&seekTo={{consumer.seekTo}}"
+ "&groupId={{consumer.group}}")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Message message = exchange.getIn();
Object data = message.getBody();
System.out.println(data);
}
})
.to("seda:end");
});
context.start();
ConsumerTemplate template=context.createConsumerTemplate();
String info=template.receiveBody("seda:end",String.class);
System.out.println(info);
}
I am having below issues:
template.start();
to start your Consumer. See this link for an example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.