PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 19, 2022

[FIXED] How to consume messages from a specific partition of a topic in kafka

 September 19, 2022     apache-kafka, c, consumer, librdkafka, partition     No comments   

Issue

I want a kafka consumer to consume messages from a particular/specified partition of a topic

It works using kafka-console-consumer.sh with switch --partition partition_number

I am using kafka_complex_consumer_example.c code from librdkafka

Upon static code analysis, I feel it can serve my purpose but I am not able to find out the exact command line parameters to be passed to main(int argc & char **argv) function for the code to run and start consuming on a topic's particular partition.

Have a look at the code here - rdkafka_complex_consumer_example.c

Full github code of librdkafka here FYR

If this code doesn't serve the purpose, please specify some other code that can help


Solution

If you look at the usage string, putting a colon after the topic name designates which partition to consume from

More specifically, topicpartition type holds information for a specific partition, and this line creates the list of those

https://github.com/edenhill/librdkafka/blob/master/examples/rdkafka_complex_consumer_example.c#L528



Answered By - OneCricketeer
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing