Apache Kafka® Consumer Example using SpringBoot 3 | Consumer Groups | Java Techie

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • In this tutorial, we will be creating a simple Kafka consumer using Spring Boot 3.0 and will understand below key points
    👉 How to consume events from topic
    👉 How kafka makes partition and consumer mapping
    👉 Offset Explorer to visualize kafka events and lags
    #JavaTechie #SpringBoot #Kafka
    Spring boot microservice Premium course lunched with 70% off 🚀 🚀
    Hurry-up & Register today itself!
    COURSE LINK : javatechie5246...
    PROMO CODE : JAVATECHIE50
    GitHub:
    github.com/Jav...
    Blogs:
    / javatechie
    Facebook:
    / javatechie
    Join this channel to get access to perks:
    www.youtube.co...
    guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
    Disclaimer/Policy:
    --------------------------------
    Note : All uploaded content in this channel is mine and its not copied from any community ,
    you are free to use source code from above mentioned GitHub account

КОМЕНТАРІ • 92

  • @amankumar-f4n5r
    @amankumar-f4n5r Рік тому +4

    just started watching your video of kafka today at 10 am morning. I couldn't stop myself and its 2 am next day just completed your all videos of kafka with hands on. Just one suggestions keep your kafka consumer topic in kafka playlist otherwise many can miss tracking this .Also i'm waiting for other kafka topics like kafka connect with database where messages are being received from different source system which kafka server listen and stores those in our database and vice versa

    • @Javatechie
      @Javatechie  Рік тому +3

      Waoo super excitement.thanks buddy i will definitely cover all concepts of Kafka

  • @vaishalis
    @vaishalis 9 місяців тому +1

    Hi Basant, thank you for an excellent informative video. What I do not understand about the lag is, if Kafka stores the messages for minimum one week, then why do we have to republish the messages which are in the lag. Why it will not automatically be reprocessed when the consumer is back up and running?

    • @Javatechie
      @Javatechie  9 місяців тому

      It will automatically be consumed by the consumer once it goes back to online. But republish required when you want to resend a particular events

  • @LearncodewithMuneeb
    @LearncodewithMuneeb Рік тому

    Thanks sir for making useful videos for us.
    But I request you very respectfully to work in a project in spring boot having at least 6 entities/tables using spring boot in the back end and React/Angular/Next in the front end

  • @Зебратв-п7э
    @Зебратв-п7э Рік тому +3

    thank you for your tutuorial easy to understand
    but i have question is it possible to miss data in kafka between producer and consumer process
    if it likes that how can i avoid missing data

    • @Javatechie
      @Javatechie  Рік тому +1

      We need to implement a retry i will cover that

  • @ankurverma4592
    @ankurverma4592 8 місяців тому

    awesome explanation able to learn the whole very well. Thank you

  • @satyabatigoswami1735
    @satyabatigoswami1735 6 місяців тому +4

    Got to understand kafka by following your tutorials. So clear explanation!! You are great😇

  • @amankumar-f4n5r
    @amankumar-f4n5r Рік тому +1

    you are awesome Basant

  • @raghugattu296
    @raghugattu296 Рік тому +2

    Hi,
    Instead of creating new consumer groups, can we not increase threads count to 3 in one method using thread property?

    • @Javatechie
      @Javatechie  Рік тому

      I will cover that content buddy

  • @geekdeb5363
    @geekdeb5363 Рік тому +1

    Great , If you can enlighten on the real time project prospective, it would be great

    • @Javatechie
      @Javatechie  Рік тому +2

      I will do one e2e project using microservice that time will cover that scenario

    • @geekdeb5363
      @geekdeb5363 Рік тому +1

      @@Javatechie Thank you 😊

  • @mohammedsardar3779
    @mohammedsardar3779 Рік тому +2

    Mesage consumption is decided by leader broker and not by the zookeeper. Zukeeper will be keeping the status of brokers and act as coordinator for all the brokers. Am I wrong Basant?

  • @entertainer-xyz7562
    @entertainer-xyz7562 8 місяців тому +1

    Hi Basant , I was going through this Kafka tutorial, I got a question on groupid that you have assigned to multiple consumers. My question is can we provide different groupid to different consumers?

    • @Javatechie
      @Javatechie  8 місяців тому

      Yes we can I just defined it to same consumer to just demonstrate partition and consumer relationship

  • @Chinmay0692010
    @Chinmay0692010 10 місяців тому +1

    If consumers get shut down while consuming, so if we start again the consumers , will it not take those messages which was not consumed….?

    • @Javatechie
      @Javatechie  10 місяців тому

      Yes he will start picking based on what last offset he read before

  • @royjose.
    @royjose. 4 місяці тому +1

    once the consumer is enabled again, will the lag values reach the consumer automatically?

    • @Javatechie
      @Javatechie  4 місяці тому +1

      Yes it will process automatically once consumer back to online

  • @SivaChaitanyaReddySanivarapu
    @SivaChaitanyaReddySanivarapu Рік тому +3

    Great topic, we are using this in my billing project

  • @Gsuresh_3
    @Gsuresh_3 Рік тому +1

    Hello, Recently I faced a question in interview, if I give a java project along with remote server without any IDE how you run that project. Can you make a video on it

  • @shubhammotghare783
    @shubhammotghare783 29 днів тому

    Hey, 1st of all thank you for the great tutorial. I've one question. When you change the group-id in service class, is it not mandatory to change or add that new group-id in application.yml ?

  • @BhanuNandanaPavanKumarBavirise
    @BhanuNandanaPavanKumarBavirise 11 днів тому

    How to write consumer instances dynamically in a single method...for every consumer instance you have created one method but only one method should multiple consumer instances naa?

  • @saurabhmaurya6964
    @saurabhmaurya6964 10 місяців тому +1

    how can we fetch all the messages from the particular topic after hitting end-point url ?..Help me with this..I tried To do with the help of KafkaConsumer consumer .. this has a method poll .. but after hitting end point i'm getting null in consumer..please help me with this ..

    • @Javatechie
      @Javatechie  10 місяців тому

      What field you are getting null ?

    • @saurabhmaurya6964
      @saurabhmaurya6964 10 місяців тому +1

      @@Javatechie in the consumer.poll section..can we connect seperately on meet so I can show you there?..

    • @Javatechie
      @Javatechie  10 місяців тому

      @@saurabhmaurya6964 sure please drop me an email to javatechie4u@gmail.com

  • @ravi.m4954
    @ravi.m4954 Рік тому +2

    Nice explanation. Can you cover in upcoming videos like how can we replay or retry lagged messages and how to identify which messages lagged and how to replay those .

  • @dileepkumarsattaru1909
    @dileepkumarsattaru1909 Рік тому +3

    Nice Basant, Keep going with this series...

  • @NareshSilpa-o1h
    @NareshSilpa-o1h Рік тому +1

    Hi brother, Good Evening, i would like to join your - Spring boot & Micro service sessions. so Kindly guide me on that, How to register and talk to you. Thanks!

    • @Javatechie
      @Javatechie  Рік тому

      Hello buddy please checkout any video description I have shared the course link and coupon code for course but still if you are getting confused then please refer to this video ua-cam.com/video/84KZa4dFLTo/v-deo.html

  • @AleksandarT10
    @AleksandarT10 Рік тому +2

    Great video!
    Explains how Kafka Consumers work pretty clearly. As an idea for the next video/s, you can go over more of the properties of Kafka for Producers/Consumers - and explain concepts like batching, the most common properties that can be configured (like manual acknowledgement or not) etc

    • @Javatechie
      @Javatechie  Рік тому +3

      Thanks for the tips! That's what's on my queue 🤪

  • @RochaNahuel
    @RochaNahuel 11 місяців тому +1

    The example is clear and I like it , but these 3 consumers who are listening to the same topic and working together , could call the same method of the logica layer without problems ?

    • @Javatechie
      @Javatechie  11 місяців тому

      Yes no problem at all because message will not be duplicate

  • @siddharthanepal1962
    @siddharthanepal1962 Рік тому +1

    Hi can you make video for how kafka handle duplicates events or messages. What if producer send same events/message twice and how consumer will acknowledge the duplicates?

    • @Javatechie
      @Javatechie  Рік тому

      Okay sure i will do that

    • @rakushhkar4225
      @rakushhkar4225 Рік тому

      How does your Producer send messages in the Queue is most important. If you send messages in a sequential way using some ID like OrderId then the message content may be duplicated but atleast the order is not. Resending messages is required if original previous message were not processed properly. There is Transaction API that supports Once Processing. Alternative is to have a Dedupe check on Consumer. But why are you insisting on non to allow duplicate messages is to be answered by you.

    • @siddharthanepal1962
      @siddharthanepal1962 Рік тому

      @rakushhkar4225 Recently, in an interview, I got this question. The interviewer asked me what happens when an exception occurs during message processing on the consumer side. How will the consumer process the failed messages? I am a beginner with kafka. If you have some videos tutorial or sameple codes, please suggest.

    • @rakushhkar4225
      @rakushhkar4225 Рік тому +2

      @@siddharthanepal1962 Also better get RabbitMQ installed to see the console where all messages are processed and stored and the parameter D is very important. Work on Stream and Quorum messages in detail too along with Classic type

    • @mohammedsardar3779
      @mohammedsardar3779 Рік тому +2

      There is an Idempotency property along with producer that helps here to avoid duplicates message process. Just shared a point of knowledge. If this is enabled broker will ignore the repetative message for uniqueness.

  • @kartikjain3064
    @kartikjain3064 Рік тому +1

    Hi, so we no need of define ProducerFactory, ConsumerFactory in our code

    • @Javatechie
      @Javatechie  Рік тому

      That will be my next video don't worry

  • @SandeepPuvvada-u5p
    @SandeepPuvvada-u5p Рік тому +1

    Good Explanation basant. Great work. I have one quick question you change the group id in the java class but not changed in yml still application works fine. Then what is the point of adding the group id in yml.

    • @Javatechie
      @Javatechie  Рік тому

      Either or you can add buddy. I forgot to mention that in video

  • @dhamodharankrishnamoorthi1921
    @dhamodharankrishnamoorthi1921 4 місяці тому

    How i can create multiple consumer group, and consume message concurrent please explain

  • @rahulprakash5045
    @rahulprakash5045 4 місяці тому +1

    is it required to add consumer group ?

    • @Javatechie
      @Javatechie  4 місяці тому

      Yes it's mandatory steps to do

  • @VIKASSINGH-jf6jd
    @VIKASSINGH-jf6jd Рік тому +1

    Basant. How do you create this beautiful presentation ? Which tool do you use or animation ?

    • @Javatechie
      @Javatechie  Рік тому

      No animation buddy it's simple Microsoft power point

  • @gauravsrivastava3884
    @gauravsrivastava3884 Рік тому +1

    Hi Basant !! Can you please all the necessary videos of this particular Kafka series to a UA-cam Playlist. It will make it easy to access all relevant videos from one place. And as and when you create new videos, you can add them to the playlist. Thanks!

  • @appstude6247
    @appstude6247 Рік тому

    thank you for the video. can please tell me what's will happen if you start kafka-consumer-example project twice ? how many consumer will have ? 3 consumer in each instance ?

  • @RaviKumar-v9b6m
    @RaviKumar-v9b6m 5 місяців тому

    Hi can you create videos on Kafka stream?

  • @GunelMammadova93
    @GunelMammadova93 6 місяців тому +1

    Thanks for the amazing tutorial!

  • @saurabhsuradkar1626
    @saurabhsuradkar1626 8 місяців тому

    consumer is not able to receive msg or connect to broker

  • @ReplayButton_7518
    @ReplayButton_7518 10 місяців тому

    It is not working for me can , the message producer worked fine but I got nothing on message consumer

    • @CharanSaiAnnam
      @CharanSaiAnnam 9 місяців тому

      Share your repository we will debug

  • @saravanakumars52
    @saravanakumars52 Рік тому +1

    What about @EnableKafka annotation??

  • @pavanreddy3162
    @pavanreddy3162 7 місяців тому

    how long the messages are store in kafka?

  • @hanumanthram6754
    @hanumanthram6754 Рік тому +1

    If the consumer is stopped then it should continue to consume the data based on the offset. is that correct understanding?

    • @Javatechie
      @Javatechie  Рік тому

      No if the consumer is shut down then what to consume and who will consume buddy?

    • @hanumanthram6754
      @hanumanthram6754 Рік тому

      @@Javatechie I mean if that consumer stopped nd again restarted that consumer will continue to consume the data based on offset. Is that not possible. Like in real-time producer produced data and stored in topic and consumer should consume data and put that in database if consumer server stopped in the middle and again again restarted can't that consumer group continue to consume the data based on offset? It is my question

    • @hanumanthram6754
      @hanumanthram6754 Рік тому +1

      Offset Management:
      1. Kafka maintains the offset for each consumer group. When a consumer reads messages from a topic, it keeps track of the offset of the last message it has processed for each partition.
      The offset is stored in a Kafka topic called __consumer_offsets. Kafka brokers manage the offset commits and offsets are periodically committed by the consumer group coordinator.
      Consumer Restart Behavior:
      2. When a consumer is stopped or goes down, the next time it restarts, it will retrieve its last committed offset for each partition from the __consumer_offsets topic.
      Upon restarting, the consumer will begin to consume messages from the topics starting at the last committed offset for each partition.
      This ensures that the consumer continues from where it left off, processing messages that were not yet consumed before the shutdown

  • @VINOTHCH
    @VINOTHCH 7 місяців тому

    @javatechie i need your help to complete a work. it is very urgent i'm subscribing a topic and i need to interpret the topic message and save it dynamodb

    • @Javatechie
      @Javatechie  7 місяців тому

      Are you using SQS ?

    • @VINOTHCH
      @VINOTHCH 7 місяців тому

      @@Javatechie I’m using Kafka

  • @arunprabu6137
    @arunprabu6137 11 місяців тому

    Bro how to connect offset kafka

  • @PradeepKumar-sx6ms
    @PradeepKumar-sx6ms Рік тому +1

    Are any videos on kafka coming?

  • @ramsharan4229
    @ramsharan4229 Рік тому +1

    awesome

  • @rishiraj2548
    @rishiraj2548 Рік тому +1

    🙏💯

  • @maximilian_gl
    @maximilian_gl Рік тому +1

    Very nice and helpful!

  • @SystemDesign-fn9zu
    @SystemDesign-fn9zu 5 місяців тому +1

    Thanks

    • @Javatechie
      @Javatechie  5 місяців тому

      Thank you buddy 😊

  • @sharmarahul17
    @sharmarahul17 9 місяців тому

    Excellent video!

  • @pnamm6501
    @pnamm6501 Рік тому +1

    Great video. Can you cover avro schema and retry mechanism and also how handle any exception when processing message consumption?

    • @Javatechie
      @Javatechie  Рік тому

      I will do that exception handling

  • @Derrick-f8m
    @Derrick-f8m Рік тому

    The GOAT

  • @aces8481
    @aces8481 4 місяці тому

    bro zoom in lol the text is tiny at times