usman
usman

Reputation: 1401

using apache camel's camel-kafka component to commit consumer offsets manually

I was able to play with apache kafka commit offset classes and able to commit using ConsumerConnector. I looked in to apache camel-kafka component having consumer option as "autoCommitEnable" same as "auto.commit.enable" property. Now is there any property or method in Camel Java DSL where after consuming a message we can commit offsets manually (through provided methods or consumer options in URL) OR we have to again use Kafka Consumer API's to commit consumer offsets?

Upvotes: 6

Views: 1625

Answers (1)

Kavya K
Kavya K

Reputation: 11

You can commit using KafkaManualCommit

Please check the documentation https://github.com/apache/camel/blob/master/components/camel-kafka/src/main/docs/kafka-component.adoc#using-manual-commit-with-kafka-consumer

public void process(Exchange exchange) {
    KafkaManualCommit manual =
        exchange.getIn().getHeader(KafkaConstants.MANUAL_COMMIT, KafkaManualCommit.class);
    manual.commitSync();
}

Upvotes: 0

Related Questions