Comments (3)
Could you confirm the versions/releases of Kafka, ZooKeeper and the
clj-kafka lib you're using please.
Thanks,
Paul
On Fri, Jan 8, 2016 at 1:58 PM, Rakesh [email protected] wrote:
Started zookeeper on port 2181
Started kafka broker on 9092Inserted few messages using console producer in test topic
bin/kafka-console-producersh --topic test --broker-list localhost:9092
Consumed messages using console consumer in test topic
bin/kafka-console-consumersh --zookeeper localhost:2181 --topic test
Running kafka offset checker script returns the following output
bin/kafka-consumer-offset-checkersh --zookeeper localhost:2181 --topic test --group console-consumer-54827
Group Topic Pid Offset logSize Lag Owner
console-consumer-54827 test 0 17 17 0 console-consumer-54827_xxxExecuting fetch-consumer-offsets function is returning the following error
(fetch-consumer-offsets "localhost:9092"
{"zookeeperconnect" "localhost:2181"}
"test"
"console-consumer-54827"){"test:0" #object[kafkacommonOffsetMetadataAndError 0x4d7f1000
"OffsetMetadataAndError[-1,,0]"]}
I am not able to figure out what wrong I am doing Can someone please help
me—
Reply to this email directly or view it on GitHub
#75.
from clj-kafka.
Kafka: kafka_2.11-0.8.2.2
Zookeeper: zookeeper-3.4.6
clj-kafka: 0.3.4
from clj-kafka.
I ran into this problem yesterday and after a round of digging in the Clojure source code (specifically, in fn clj-kafka.offset/fetch-consumer-offsets
, I found the culprit.
It is the versionId
of kafka.api.OffsetFetchRequest
that determines where to fetch consumer offsets from. Quoting this guide to the Apache Kafka protocol:
There is no format difference between Offset Fetch Request v0 and v1. Functionality wise, Offset Fetch Request v0 will fetch offset from zookeeper, Offset Fetch Request v1 will fetch offset from Kafka.
So when an instance of kafka.api.OffsetFetchRequest
is created in clj-kafka.offset/offset-fetch-request
, versionId
is hard-coded to 1
, that causes consumer offsets to be fetched from Kafka, which simply returns consumer offsets of -1
as response since in version 0.8.x, consumer offsets are stored in ZooKeeper, instead of Kafka. In order to get the correct consumer offsets from ZooKeper, versionId
needs to be set to 0
. The following is a little function that I wrote based on clj-kafka.offset/offset-fetch-request
that fetches consumer offsets from ZooKeeper:
(defn offset-fetch-request [group-id topic max-partition]
(let [offset-request-version 0 ; version 0 fetches from ZooKeeper, version 1 and above fetch from Kafka.
correlation-id 1
topic-partition-java (map (fn [i] (kafka.common.TopicAndPartition. topic i)) (range 0 max-partition))
topic-partition-scala (.toSeq (scala.collection.JavaConversions/asScalaBuffer topic-partition-java))]
(kafka.api.OffsetFetchRequest. group-id topic-partition-scala offset-request-version correlation-id "clj-kafka-id")))
So one can use the function above to write another function that's similar to clj-kafka.offset/fetch-consumer-offsets
.
from clj-kafka.
Related Issues (20)
- data.json vs cheshire HOT 1
- README.md New Producer example error
- clj-kafka.new.producer/producer code error HOT 1
- release 0.3.2 HOT 1
- Expose with-test-broker? HOT 1
- Make test helpers available HOT 1
- Readme port numbers.
- Offset management HOT 6
- Convert Kafka byte-array to String\json HOT 3
- Implement new KafkaConsumer
- Add more options to `messages` method for simple consumer HOT 4
- Update to Kafka 0.9 HOT 11
- I cannot get messages using clj-kafka.consumer.zk HOT 2
- new producer send callback not invoked HOT 2
- Any reason for an old Clojure dep?
- Does this breaks with clojure 1.8? HOT 4
- [doc] Request for a CHANGELOG
- Upgrade for newer Kafka Versions HOT 1
- how to handle zk disconnect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clj-kafka.