-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible for consumer to seek to a given offset in the topic? #1
Comments
That function is listed in the "legacy consumer" part of librdkafka's code. Do you know if it works with the high level consumer in librdkafka? Otherwise, you can always use |
Sorry, I'm not sure if that works in the high level consumer. I did try using Here's what I did:
Questions:
|
Can't you just subscribe to the topic and use Also, what do you mean "it fails"? |
I've used this on some application I wrote and it works as expected. Did you manage to make it work? Just assign and you'll start getting messages for that offset. |
Closing as this should work as expected. If you couldn't make it work, please re-open. |
…ck()) Stack traces: (gdb) #0 0x000055697b8f2140 in ?? () mfontanini#1 0x00007f10a393a514 in cppkafka::log_callback_proxy(rd_kafka_s const*, int, char const*, char const*) () from /usr/lib/libcppkafka.so.0.1 (gdb) bt #0 0x00007f10a0d44a0d in __GI___pthread_timedjoin_ex (threadid=139697179305728, thread_return=0x7ffc7f574f70, abstime=0x0, block=<op timized out>) at pthread_join_common.c:89 mfontanini#1 0x00007f10a36d1640 in ?? () from /usr/lib/x86_64-linux-gnu/librdkafka.so.1 mfontanini#2 0x00007f10a36718ff in rd_kafka_destroy () from /usr/lib/x86_64-linux-gnu/librdkafka.so.1 mfontanini#3 0x00007f10a47f79af in __base_dtor () at /usr/include/c++/7/bits/unique_ptr.h:268 mfontanini#4 __base_dtor (this=0x55697b8ed260) at /usr/include/cppkafka/kafka_handle_base.h:63
…ck()) Configuration should exist for logging, since it contains the copy of the callback. Stack traces: (gdb) #0 0x000055697b8f2140 in ?? () mfontanini#1 0x00007f10a393a514 in cppkafka::log_callback_proxy(rd_kafka_s const*, int, char const*, char const*) () from /usr/lib/libcppkafka.so.0.1 (gdb) bt #0 0x00007f10a0d44a0d in __GI___pthread_timedjoin_ex (threadid=139697179305728, thread_return=0x7ffc7f574f70, abstime=0x0, block=<op timized out>) at pthread_join_common.c:89 mfontanini#1 0x00007f10a36d1640 in ?? () from /usr/lib/x86_64-linux-gnu/librdkafka.so.1 mfontanini#2 0x00007f10a36718ff in rd_kafka_destroy () from /usr/lib/x86_64-linux-gnu/librdkafka.so.1 mfontanini#3 0x00007f10a47f79af in __base_dtor () at /usr/include/c++/7/bits/unique_ptr.h:268 mfontanini#4 __base_dtor (this=0x55697b8ed260) at /usr/include/cppkafka/kafka_handle_base.h:63
…ck()) Configuration should exist for logging, since it contains the copy of the callback. Stack traces: (gdb) #0 0x000055697b8f2140 in ?? () mfontanini#1 0x00007f10a393a514 in cppkafka::log_callback_proxy(rd_kafka_s const*, int, char const*, char const*) () from /usr/lib/libcppkafka.so.0.1 (gdb) bt #0 0x00007f10a0d44a0d in __GI___pthread_timedjoin_ex (threadid=139697179305728, thread_return=0x7ffc7f574f70, abstime=0x0, block=<op timized out>) at pthread_join_common.c:89 mfontanini#1 0x00007f10a36d1640 in ?? () from /usr/lib/x86_64-linux-gnu/librdkafka.so.1 mfontanini#2 0x00007f10a36718ff in rd_kafka_destroy () from /usr/lib/x86_64-linux-gnu/librdkafka.so.1 mfontanini#3 0x00007f10a47f79af in __base_dtor () at /usr/include/c++/7/bits/unique_ptr.h:268 mfontanini#4 __base_dtor (this=0x55697b8ed260) at /usr/include/cppkafka/kafka_handle_base.h:63
Same issue. cppkafka::TopicPartitionList assignments;
offset = TopicPartition::OFFSET_END;
assignments.push_back({topicName, partition, offset});
consumer->assign(assignments);
cout << consumer->get_offsets(consumer->c->get_assignment()[0]); always gives an INVALID_OFFSET. And consumer doesn't consume anything. |
If this were to be an issue, it would be on rdkafka's side. cppkafka is just a very thin layer on top of it. Have you checked the documentation for that call in rdkafka's side? Quoting it:
It is possible you're querying the offset too quickly and it's still unknown to the library.
Are you producing messages on that topic/partition? Your consumer will be pointing to the end of the log so you need to produce something after you subscribe for the consumer to receive something. |
Of course I'm producing on this topic/partition. And bundled kafka console-consumer can read messages. My consumer can't |
I've just tried this locally using rdkafka v0.11.4 and it works as expected. I do get INVALID_OFFSET after querying right after calling Are you using the latest version of rdkafka? Again, cppkafka is a super thin layer on top of rdkafka so odds are if there's actually an issue, it's on rdkafka's side and you should create a ticket on their repo. |
Okay, thank you very much! I'll continue digging things |
As far as I could understand, there is a recommendation to use function |
|
Something like this in the Java API:
https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html#seek(org.apache.kafka.common.TopicPartition,%20long)
and in librdkafka:
https://github.com/edenhill/librdkafka/blob/master/src/rdkafka.c#L1735
The text was updated successfully, but these errors were encountered: