Kafka Consumer is not reading the topic data through Java2019 Community Moderator ElectionKafka consumer not returning any eventsHow do I read / convert an InputStream into a String in Java?is it possible to exclude a topic from a broker in kafkakafka consumer to dynamically detect topics addedkafka custom consumer to read incoming recordsHow to get the relationship of consumer group and topicsConsumer not receiving message in Apache KafkaKafka: Consumer can't read records from topicKafka Consumer seektoBeginningKafka consumer to unzip stream of gz files and readRe-use of existing kafka consumer that has been idle for long duration

When were linguistics departments first established

Counter-example to the existence of left Bousfield localization of combinatorial model category

Can the druid cantrip Thorn Whip really defeat a water weird this easily?

What is the definition of "Natural Selection"?

Is a lawful good "antagonist" effective?

Make a transparent 448*448 image

Need some help with my first LaTeX drawing…

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

Time dilation for a moving electronic clock

How can I discourage/prevent PCs from using door choke-points?

Deleting missing values from a dataset

Is going from continuous data to categorical always wrong?

The three point beverage

Does splitting a potentially monolithic application into several smaller ones help prevent bugs?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

What to do when during a meeting client people start to fight (even physically) with each others?

Plywood subfloor won't screw down in a trailer home

Want to switch to tankless, but can I use my existing wiring?

Replacing Windows 7 security updates with anti-virus?

Word for a person who has no opinion about whether god exists

What is the difference between "shut" and "close"?

My story is written in English, but is set in my home country. What language should I use for the dialogue?

What exactly is the purpose of connection links straped between the rocket and the launch pad

Why don't MCU characters ever seem to have language issues?



Kafka Consumer is not reading the topic data through Java



2019 Community Moderator ElectionKafka consumer not returning any eventsHow do I read / convert an InputStream into a String in Java?is it possible to exclude a topic from a broker in kafkakafka consumer to dynamically detect topics addedkafka custom consumer to read incoming recordsHow to get the relationship of consumer group and topicsConsumer not receiving message in Apache KafkaKafka: Consumer can't read records from topicKafka Consumer seektoBeginningKafka consumer to unzip stream of gz files and readRe-use of existing kafka consumer that has been idle for long duration










2















I am sending input JSON data to Kafka topic. I can see the same JSON data in kafka consumer by using below command.



.binwindowskafka-console-consumer.bat --bootstrap-server localhost:9092 --topic mytopic --from-beginning


Case1:
But when I am trying to read the records from kafka consumer (java) not getting any records in java console. I have tried the examples given in this link https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html



Case2:
If I send any message from the producer (command window) the same getting in the consumer(command window). and able to see the same records in the java console. This scenario is working.



If I submit the data to the topic through java program. Then the same JSON data appearing in consumer(command window). But not coming in java console.Case1 is not working.
Case2 is working. Please let me know any configuration need to be done?










share|improve this question
























  • so you start consuming from java and then send new data to the topic and no messages appear (case 1)?

    – tgrez
    Mar 7 at 11:14











  • Are you running case2 using only one JVM?

    – Lyubomir Papazov
    Mar 7 at 11:19











  • Possible duplicate of Kafka consumer not returning any events

    – wardziniak
    Mar 7 at 11:23






  • 1





    How did you write your producer? Share us your code.

    – JR ibkr
    Mar 7 at 15:39











  • Start both console-consumer and custom-consumer. Then run your java producer. Also, make sure that your producer sends messages to Kafka. Do you see messages on both consumers ?

    – JR ibkr
    Mar 7 at 15:46















2















I am sending input JSON data to Kafka topic. I can see the same JSON data in kafka consumer by using below command.



.binwindowskafka-console-consumer.bat --bootstrap-server localhost:9092 --topic mytopic --from-beginning


Case1:
But when I am trying to read the records from kafka consumer (java) not getting any records in java console. I have tried the examples given in this link https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html



Case2:
If I send any message from the producer (command window) the same getting in the consumer(command window). and able to see the same records in the java console. This scenario is working.



If I submit the data to the topic through java program. Then the same JSON data appearing in consumer(command window). But not coming in java console.Case1 is not working.
Case2 is working. Please let me know any configuration need to be done?










share|improve this question
























  • so you start consuming from java and then send new data to the topic and no messages appear (case 1)?

    – tgrez
    Mar 7 at 11:14











  • Are you running case2 using only one JVM?

    – Lyubomir Papazov
    Mar 7 at 11:19











  • Possible duplicate of Kafka consumer not returning any events

    – wardziniak
    Mar 7 at 11:23






  • 1





    How did you write your producer? Share us your code.

    – JR ibkr
    Mar 7 at 15:39











  • Start both console-consumer and custom-consumer. Then run your java producer. Also, make sure that your producer sends messages to Kafka. Do you see messages on both consumers ?

    – JR ibkr
    Mar 7 at 15:46













2












2








2








I am sending input JSON data to Kafka topic. I can see the same JSON data in kafka consumer by using below command.



.binwindowskafka-console-consumer.bat --bootstrap-server localhost:9092 --topic mytopic --from-beginning


Case1:
But when I am trying to read the records from kafka consumer (java) not getting any records in java console. I have tried the examples given in this link https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html



Case2:
If I send any message from the producer (command window) the same getting in the consumer(command window). and able to see the same records in the java console. This scenario is working.



If I submit the data to the topic through java program. Then the same JSON data appearing in consumer(command window). But not coming in java console.Case1 is not working.
Case2 is working. Please let me know any configuration need to be done?










share|improve this question
















I am sending input JSON data to Kafka topic. I can see the same JSON data in kafka consumer by using below command.



.binwindowskafka-console-consumer.bat --bootstrap-server localhost:9092 --topic mytopic --from-beginning


Case1:
But when I am trying to read the records from kafka consumer (java) not getting any records in java console. I have tried the examples given in this link https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html



Case2:
If I send any message from the producer (command window) the same getting in the consumer(command window). and able to see the same records in the java console. This scenario is working.



If I submit the data to the topic through java program. Then the same JSON data appearing in consumer(command window). But not coming in java console.Case1 is not working.
Case2 is working. Please let me know any configuration need to be done?







java apache-kafka kafka-consumer-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 16:03









iehrlich

3,22242640




3,22242640










asked Mar 7 at 10:59









Praveen KumarPraveen Kumar

114




114












  • so you start consuming from java and then send new data to the topic and no messages appear (case 1)?

    – tgrez
    Mar 7 at 11:14











  • Are you running case2 using only one JVM?

    – Lyubomir Papazov
    Mar 7 at 11:19











  • Possible duplicate of Kafka consumer not returning any events

    – wardziniak
    Mar 7 at 11:23






  • 1





    How did you write your producer? Share us your code.

    – JR ibkr
    Mar 7 at 15:39











  • Start both console-consumer and custom-consumer. Then run your java producer. Also, make sure that your producer sends messages to Kafka. Do you see messages on both consumers ?

    – JR ibkr
    Mar 7 at 15:46

















  • so you start consuming from java and then send new data to the topic and no messages appear (case 1)?

    – tgrez
    Mar 7 at 11:14











  • Are you running case2 using only one JVM?

    – Lyubomir Papazov
    Mar 7 at 11:19











  • Possible duplicate of Kafka consumer not returning any events

    – wardziniak
    Mar 7 at 11:23






  • 1





    How did you write your producer? Share us your code.

    – JR ibkr
    Mar 7 at 15:39











  • Start both console-consumer and custom-consumer. Then run your java producer. Also, make sure that your producer sends messages to Kafka. Do you see messages on both consumers ?

    – JR ibkr
    Mar 7 at 15:46
















so you start consuming from java and then send new data to the topic and no messages appear (case 1)?

– tgrez
Mar 7 at 11:14





so you start consuming from java and then send new data to the topic and no messages appear (case 1)?

– tgrez
Mar 7 at 11:14













Are you running case2 using only one JVM?

– Lyubomir Papazov
Mar 7 at 11:19





Are you running case2 using only one JVM?

– Lyubomir Papazov
Mar 7 at 11:19













Possible duplicate of Kafka consumer not returning any events

– wardziniak
Mar 7 at 11:23





Possible duplicate of Kafka consumer not returning any events

– wardziniak
Mar 7 at 11:23




1




1





How did you write your producer? Share us your code.

– JR ibkr
Mar 7 at 15:39





How did you write your producer? Share us your code.

– JR ibkr
Mar 7 at 15:39













Start both console-consumer and custom-consumer. Then run your java producer. Also, make sure that your producer sends messages to Kafka. Do you see messages on both consumers ?

– JR ibkr
Mar 7 at 15:46





Start both console-consumer and custom-consumer. Then run your java producer. Also, make sure that your producer sends messages to Kafka. Do you see messages on both consumers ?

– JR ibkr
Mar 7 at 15:46












3 Answers
3






active

oldest

votes


















0














You need to set the ConsumerConfig.AUTO_OFFSET_RESET_CONFIG in order to read from the beginning.



kafkaConsumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"earliest"); 


And also make sure that you are not running different-different consumer processes using the same consumer group ID, as the data from one partition might be read from one process and another will not see anything.






share|improve this answer






























    0














    Assuming producer & consumer code is correct.



    • Stop all consumers.

    • Reset your consumer group


    $KAFKA_HOME/bin/kafka-consumer-groups.sh --bootstrap-server
    localhost:9092 --group group_name --topic topic_name --reset-offsets
    --to-earliest --execute




    • Now start your consumer

    This should fix your issue.



    Here are some Kafka consumer properties:



     bootstrap.servers: 'localhost:9092'
    group.id: 'group_id'
    auto.offset.reset: 'earliest'
    key.deserializer: 'org.apache.kafka.common.serialization.*' //Replace * with class
    value.deserializer: 'org.apache.kafka.common.serialization.*'


    Thanks






    share|improve this answer
































      0














      You need to make sure you are not sending empty lines at the end and only consuming the latest - use auto.offset.reset: 'earliest' like above, or properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");



      And then,
      consumer.seekToBeginning(consumer.assignment()); to make sure.






      share|improve this answer






















        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042190%2fkafka-consumer-is-not-reading-the-topic-data-through-java%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        You need to set the ConsumerConfig.AUTO_OFFSET_RESET_CONFIG in order to read from the beginning.



        kafkaConsumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"earliest"); 


        And also make sure that you are not running different-different consumer processes using the same consumer group ID, as the data from one partition might be read from one process and another will not see anything.






        share|improve this answer



























          0














          You need to set the ConsumerConfig.AUTO_OFFSET_RESET_CONFIG in order to read from the beginning.



          kafkaConsumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"earliest"); 


          And also make sure that you are not running different-different consumer processes using the same consumer group ID, as the data from one partition might be read from one process and another will not see anything.






          share|improve this answer

























            0












            0








            0







            You need to set the ConsumerConfig.AUTO_OFFSET_RESET_CONFIG in order to read from the beginning.



            kafkaConsumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"earliest"); 


            And also make sure that you are not running different-different consumer processes using the same consumer group ID, as the data from one partition might be read from one process and another will not see anything.






            share|improve this answer













            You need to set the ConsumerConfig.AUTO_OFFSET_RESET_CONFIG in order to read from the beginning.



            kafkaConsumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG,"earliest"); 


            And also make sure that you are not running different-different consumer processes using the same consumer group ID, as the data from one partition might be read from one process and another will not see anything.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 7 at 12:13









            Nishu TayalNishu Tayal

            12.8k73483




            12.8k73483























                0














                Assuming producer & consumer code is correct.



                • Stop all consumers.

                • Reset your consumer group


                $KAFKA_HOME/bin/kafka-consumer-groups.sh --bootstrap-server
                localhost:9092 --group group_name --topic topic_name --reset-offsets
                --to-earliest --execute




                • Now start your consumer

                This should fix your issue.



                Here are some Kafka consumer properties:



                 bootstrap.servers: 'localhost:9092'
                group.id: 'group_id'
                auto.offset.reset: 'earliest'
                key.deserializer: 'org.apache.kafka.common.serialization.*' //Replace * with class
                value.deserializer: 'org.apache.kafka.common.serialization.*'


                Thanks






                share|improve this answer





























                  0














                  Assuming producer & consumer code is correct.



                  • Stop all consumers.

                  • Reset your consumer group


                  $KAFKA_HOME/bin/kafka-consumer-groups.sh --bootstrap-server
                  localhost:9092 --group group_name --topic topic_name --reset-offsets
                  --to-earliest --execute




                  • Now start your consumer

                  This should fix your issue.



                  Here are some Kafka consumer properties:



                   bootstrap.servers: 'localhost:9092'
                  group.id: 'group_id'
                  auto.offset.reset: 'earliest'
                  key.deserializer: 'org.apache.kafka.common.serialization.*' //Replace * with class
                  value.deserializer: 'org.apache.kafka.common.serialization.*'


                  Thanks






                  share|improve this answer



























                    0












                    0








                    0







                    Assuming producer & consumer code is correct.



                    • Stop all consumers.

                    • Reset your consumer group


                    $KAFKA_HOME/bin/kafka-consumer-groups.sh --bootstrap-server
                    localhost:9092 --group group_name --topic topic_name --reset-offsets
                    --to-earliest --execute




                    • Now start your consumer

                    This should fix your issue.



                    Here are some Kafka consumer properties:



                     bootstrap.servers: 'localhost:9092'
                    group.id: 'group_id'
                    auto.offset.reset: 'earliest'
                    key.deserializer: 'org.apache.kafka.common.serialization.*' //Replace * with class
                    value.deserializer: 'org.apache.kafka.common.serialization.*'


                    Thanks






                    share|improve this answer















                    Assuming producer & consumer code is correct.



                    • Stop all consumers.

                    • Reset your consumer group


                    $KAFKA_HOME/bin/kafka-consumer-groups.sh --bootstrap-server
                    localhost:9092 --group group_name --topic topic_name --reset-offsets
                    --to-earliest --execute




                    • Now start your consumer

                    This should fix your issue.



                    Here are some Kafka consumer properties:



                     bootstrap.servers: 'localhost:9092'
                    group.id: 'group_id'
                    auto.offset.reset: 'earliest'
                    key.deserializer: 'org.apache.kafka.common.serialization.*' //Replace * with class
                    value.deserializer: 'org.apache.kafka.common.serialization.*'


                    Thanks







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 8 at 6:09

























                    answered Mar 7 at 13:26









                    Ashish BhosleAshish Bhosle

                    330110




                    330110





















                        0














                        You need to make sure you are not sending empty lines at the end and only consuming the latest - use auto.offset.reset: 'earliest' like above, or properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");



                        And then,
                        consumer.seekToBeginning(consumer.assignment()); to make sure.






                        share|improve this answer



























                          0














                          You need to make sure you are not sending empty lines at the end and only consuming the latest - use auto.offset.reset: 'earliest' like above, or properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");



                          And then,
                          consumer.seekToBeginning(consumer.assignment()); to make sure.






                          share|improve this answer

























                            0












                            0








                            0







                            You need to make sure you are not sending empty lines at the end and only consuming the latest - use auto.offset.reset: 'earliest' like above, or properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");



                            And then,
                            consumer.seekToBeginning(consumer.assignment()); to make sure.






                            share|improve this answer













                            You need to make sure you are not sending empty lines at the end and only consuming the latest - use auto.offset.reset: 'earliest' like above, or properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");



                            And then,
                            consumer.seekToBeginning(consumer.assignment()); to make sure.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Mar 8 at 7:23









                            Wisani SalaniWisani Salani

                            413




                            413



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55042190%2fkafka-consumer-is-not-reading-the-topic-data-through-java%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                                2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                                Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme