5

I am using apache camel to integerate with my kafka messaging. Also i am using JAVA DSL to consume messages from kafka endpoint.

Using apache kafka API's its known how to commit consumer offsets with given properties toggling.

if i disbale auto commit in camel-kafka component how can i commit offsets in apcahe camel then?

I am using below endpoint to disable auto commit in Apache Camel

kafka.consumer.uri = kafka://{{kafka.host}}?zookeeperHost={{zookeeper.host}}&zookeeperPort={{zookeeper.port}}&groupId={{kafka.consumerGroupId}}&topic={{kafka.topic.transformer_t}}&{{kafka.uri.options}}
kafka.uri.options = autoCommitEnable=false
usman
  • 1,351
  • 5
  • 23
  • 47
  • Did you ever find a solution for this? – konse Jan 30 '17 at 13:27
  • 2
    not really but check latest specs in Camel-Kafka if they have something. I stopped using Camel-Kafka for not supporting commit Offset manually. – usman Jan 31 '17 at 07:27
  • This was a show stopper for me too. See also: https://stackoverflow.com/questions/45947180/how-to-manually-control-the-offset-commit-with-camel-kafka – Chris Snow Nov 02 '17 at 10:12

1 Answers1

1

Support for manual offset commit was added in CAMEL-11933 and is supported since version 2.21.0. You can enable it with option allowManualCommit=true. This option will expose header CamelKafkaManualCommit, holding instance of KafkaManualCommit, which you can then use e.g. in Processor.

from("kafka:topic?groupId=group&autoCommitEnable=false&allowManualCommit=true")
  //...
  .process(exchange -> {
     exchange.getIn().getHeader(KafkaConstants.MANUAL_COMMIT, KafkaManualCommit.class).commitSync();
  });
Bedla
  • 4,789
  • 2
  • 13
  • 27