Apache Kafka® Producer Example using SpringBoot 3.x | Java Techie

Поділитися
Вставка
  • Опубліковано 10 лют 2025
  • In this tutorial, we will be creating a simple Kafka Producer using Spring Boot 3.0 and will understand below key points
    👉 Default topic create by Spring Boot
    👉 How to handle the results asynchronously in kafka producer
    👉 How to create topic programatically
    👉 How messages will be distributed to multiple partition
    👉 Offset Explorer to visualise kafka events
    #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
  • Наука та технологія

КОМЕНТАРІ • 99

  • @pulkitkaushik4539
    @pulkitkaushik4539 Рік тому +13

    Hi Basant,
    Your videos helped immensely during the interview prep time and it helped to get a decent job as Senior Software Engineer... many thnaks to you !!

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

      Glad to hear this buddy 🥰. Thank you so much keep learning

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

      send to Basant, at least some percent of your salary bro , he is doing it for free! )

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

      hey buddy, I get you're joking, but I truly enjoyed the appreciation from you guys, which means more to me than money.

  • @narmadapasumarthi9190
    @narmadapasumarthi9190 6 днів тому

    Wonderful playlist. Thanks a lot for all your efforts.

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

    Very creative and helpful video anyone can understand.
    I went through many articles and videos, and I was very confused, and my thought was Kafka is very big and very vast. But by watching this video I am full cleared on Kafka concepts.

  • @deveshagarwal660
    @deveshagarwal660 11 місяців тому +3

    Really helpful, detailed and amazing video. Keep up the good work brother.

  • @MrOpolo91
    @MrOpolo91 Рік тому +4

    Great series! Thanks for your very detailed and clear explanations... Keep it going!

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

    Java Techie, we miss you so much!!!

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

    Thank you for your videos! They are super helpful

  • @RussianCyclop
    @RussianCyclop 3 місяці тому

    Thanks, mate!
    Your tutorials are always awesome.

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

    Hi Basant, thank you for sharing kafka series. I apricate your efforts

  • @prof_as
    @prof_as 2 місяці тому +1

    Great tutorial, nicely explained. Thankyou.

  • @pottendlanagma7263
    @pottendlanagma7263 8 місяців тому +3

    very clear and concise explanation. Keep Rock!

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

    Great tutorial on Kafka. Appreciate your efforts, Basant.

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

    Amazing tutorial, thank you bro!

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

    Simply Superb

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

    Great.....God Bless you !!!!

  • @sudhakarkothapalli3342
    @sudhakarkothapalli3342 7 місяців тому +1

    Great explanation!

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

    Very nice explanation, Thank you sir.

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

    Great knowledge sharing. Hope we can see multithreading consumer tutorial

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

      Yes i will cover that with consumer group don't worry

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

    Hello @Java Techie, thank you for the amazing content , it is quite easy to understand. I have few queries,
    1. What is the importance of replicationFactor?
    2. How the kafka setup ensures delivery of message in case when consumer application is down?
    3. Is it possible to create the topics from docker-compose.yml files?

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

    Excellent video!

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

    Great video, thanks!

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

    Please post a video for setting up the consumer for the same. Amazing video

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

      Sure buddy that will be my next video.

  • @SandeepKoduri-w7j
    @SandeepKoduri-w7j Рік тому

    This is awesome !!!

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

    Hi Basant
    Thank you for Kaka tutorial. Learned a lot from you in the fast. I have few queries
    1. How can we create multiple topics programmatically? With @Bean we can create only topic at a time
    2.. If topic already exist, it throws exception. How can we skip topic creation if topic already exist.
    3. Does it creates new thread for each message send?

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

      First and Two questions are quite interesting i will check and update you but regarding the 3rd one it won't execute by a separate thread message will concurrently be distributed to multiple partitions but to get those messages you need to implement multi threading in the consumer part .
      You can even use the Executor service in the producer itself

  • @SandeepKoduri-w7j
    @SandeepKoduri-w7j Рік тому +1

    This is awesome

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

    Loved ur video, sir can u please make a video of inter service communication in spring Microserverices with real time example using kafka

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

      Buddy i have done the same in the cqrs design pattern please check that

  • @harikayejj
    @harikayejj 21 день тому +1

    Hi Basant, can we have the producer in springboot without Zookeeper

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

    👍 thanks

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

    Event Streaming with huge data reading and writing

  • @shrishailmadari8792
    @shrishailmadari8792 2 місяці тому

    and u shared the .sh commands in the git, tht killed my self confidence ,,,,,

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

    Thanks for this nice video, I have configured offset exproler but for me instead of actual message it showing hascode of message

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

      Okay just click on topic and change the type to string instead of byte

  • @narmadapasumarthi9190
    @narmadapasumarthi9190 6 днів тому

    I have a doubt. From where we are getting bean for KafkaTemplate? We haven't created that bean but we are injecting?

  • @user-0987-a
    @user-0987-a Рік тому +1

    I owe you a drink.

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

    Also looks like the messages in kafka are getting encrypted by default, I dont see actual message in offset Explorer. Is ther a way to get plain message in kafka topic

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

      No in offset you need to change the data type to json or plain text in topic itself

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

    20:09 In my scenario my data stored only partition 2. No data stored in partition 0 & 1. Why ?? @javatechie

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

      Try 2 or 3 times again it will store messages to different partition. Please check in video i mentioned why okay

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

      @@Javatechie Thanks Sir. I got it.

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

    can you please explain Kafka clustering topic using spring boot if possible

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

    Hi This is not related to this video but in General I Want to know is that Mac Air laptop will supports our all Java tools? or we need Mac pro ?? I want to shifting from windows to Mac. I need AI ,ML tool Supper as Well. pls suggest

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

      No i am using a Mac desktop with custom congratulations 16 GB . You can use a Mac pro laptop with the latest configuration to play with ai

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

    Hi Basant, thanks for knowledge sharing.can you post video on replication factor other than one and how it will behave and in this case duplicate messages will be received by consumer or not

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

    Have a quick question: if you are capturing the result into an object after sending, isn't that mean the thread will wait for result to come and it is still hampering the performance of the app ?

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

      It will just capture metadata of your records nothing else so I don't think it will impact anything on performance

  • @Unknown-explorerr
    @Unknown-explorerr Рік тому

    How it will behave when multiple instance of application are launched?? It will create different topics or adhere to same topic??

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

    Can you make video on spring boot jdbc template Mapsqlparametersource with stringutils and string builder using sql queries please

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

    Hi Basant, How do you get yml intellisense on intellij ?

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

      I believe it's by default available in the community edition but not sure whether I add any plugin or not. Can you check the plugin name spring boot assistant

  • @SubhodipBasu-p1y
    @SubhodipBasu-p1y 7 місяців тому

    How will we handle an exception and implement retry on the publisher microservice if we face issue while publishing to kafka

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

    Sir if you don't mind please mention the link of microservice playlist taught by you...

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

      Please go through it
      Microservice: ua-cam.com/play/PLVz2XdJiJQxxWhFkucZBoMxeYE6qTgEF8.html

  • @rajakannan9093
    @rajakannan9093 7 днів тому +1

    ❤❤❤❤❤❤❤❤❤❤❤❤❤

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

    Hi Basant. I have a question. We have already used KafkaTemplate and it is creating the topic if topic is not already created. Why do we need to again use NewTopic bean and pass the topic name in KafkaTemplate instance. Pls explain. Thanks

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

      Rajendra correct Kafka will create the topic but with default configuration like 1 partition and replication factor so if you want to customize it then you need to create topic by your own either using terminal or programmatically

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

      @@Javatechie oh okay. Thank you 🙏🏻

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

    Hi Basant can you please tell me how can we integrate Kafka instead of active mq with spring boot

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

      This is a Kafka integration example only right? What are you looking for?

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

    Hello Sir,, Here Topic 'java-techie-demo-3' will be created only If it is not exist already. Right?

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

    Do you have offset Explorer license to use it for the educational purpose? It is not free to use for educational purpose as mentioned on its website. Just brining to your notice.

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

      It's open source and free

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

      @@Javatechie This is what is mentioned on its website Offset Explorer is free for personal use only. Any non-personal use, including commercial, educational and non-profit work is not permitted without purchasing a license. Non-personal use is allowed for evaluation purposes for 30 days following the download of Offset Explorer, after which you must purchase a valid license or remove the software

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

      Not sure then, there might be some changes but it's installed on my machine from past 2 years and software didn't force me for any licence

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

    How can we send events in to same partition rather than round robin. Because there is order in partition but no order among partition how we provide order by sending same partition.

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

    How to listen the Kafka consume with some intervel time when producer send the data to the kafla server

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

    please share the link of the 1st video. Thanks

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

    The next part is expected soon..maybe today 😅.. thanks

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

    Hi sir
    WSL (10) ERROR: CreateProcessEntryCommon:505: execvpe /bin/bash failed 2
    WSL (10) ERROR: CreateProcessEntryCommon:508: Create process not expected to return
    getting this while starting Zookeeper

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

    Hello everyone,
    I am constantly gettinig the below given error:
    Required type: CompletableFuture
    Provided: ListenableFuture
    everytime I try declaring future variable

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

      The return type is incorrect just use your ide to get the correct return type brother

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

      @@Javatechie hello brother, I tried but I'm not getting the option to use completable future in java 11. I am using Intellij

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

      @sunnysingh7854 please share your code in GitHub.com

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

    sir i have issue to download Offset Explorer for Ubuntu system
    can provide .sh file

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

      No it's a simple DMG file for me I just need to install it

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

    Hi ..you have missed a crucial point as to how to distribute the messages among partitions using Kafka custom Partitioner

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

      I will do that buddy along with read and write part

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

    I was confused by the fact that not all messages were sent to the topic, when I'm trying to see the data only 100 messages are in presence. The reason is that you need to specify the number of messages you wanna see, hope this helps beginners not search for errors

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

      No it should send all the messages. Check the total message count in each partition

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

      @@Javatechie Everything is working well, as I said I couldn't see all the messages as there was a limit for messages that can be shown (in offset explorer)

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

      @@vladstarichenko4937 it's a free tool buddy if I will send 1000 message still it will show max 100 message in app so better to check in each partition level message count

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

    Please teach something complex like Kafka streams as not many good videos are there

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

      I will do that concept step by step

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

    How do you set idempotence= true for producer?

  • @shrishailmadari8792
    @shrishailmadari8792 2 місяці тому

    yaar app vo logs of both zookeper and kafka ka logs achhese dikhav cant able to see properly,,,

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

    🙏👍

  • @Bunnybunny-n1v
    @Bunnybunny-n1v 11 місяців тому +1

    how to start Zookeeper and kafka on windows

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

    Great series! Thanks for your very detailed and clear explanations... Keep it going!