How to push (produce ) messages into the Kafka broker using java?

                                   How to push (produce ) messages into the Kafka broker using java


  • First, create the properties class object for loading the Kafka producer properties.
  • After Connection creation of Kafka producer use the send method to push the message into the broker.
  • Finally, Close the Kafka producer connection.
Producing message into broker
import java.util.Properties; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.ProducerRecord; /** * * @author:Janardhan Randhi * @Date:Oct 23, 2018 * @Class: This class push the messages into kafka broker. */ public class Producer { public static void main(String[] args) { Properties properties = new Properties(); properties.put("bootstrap.servers", "localhost:9092"); properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); KafkaProducer kafkaProducer = new KafkaProducer(properties); try { for (int i = 0; i < 100; i++) { System.out.println(i); kafkaProducer.send(new ProducerRecord("janardhan", Integer.toString(i), "test message - " + i)); } } catch (Exception e) { e.printStackTrace(); } finally { kafkaProducer.close(); } } }

SUBSCRIBE TO OUR NEWSLETTER

I’m the Founder of quickdevops.com. I am a Professional Blogger, Application developer, YouTuber. I’ve been blogging since 2015.I spend a lot of time learning new techniques and actively help other people learn web development through a variety of help groups and writing web development tutorials for my website and blog about advancements in web design and development.Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie or planning a trip to someplace I've never been before.

29 Responses to "How to push (produce ) messages into the Kafka broker using java?"

  1. I really like your article. It’s evident that you have a lot knowledge on this topic. Your points are well made and relatable. Thanks for writing engaging and interesting material. apple phone mockup

    ReplyDelete
  2. I completely understand everything you have said. Actually, I browsed through your additional content articles and I think you happen to be absolutely right. Great job with this online site. iphone psd

    ReplyDelete
  3. Just saying thanks wouldn’t just be enough, for the fantastic fluency in your writing.
    additional reading

    ReplyDelete
  4. Hey! Good stuff, please keep us posted when you post something like that! device mockup

    ReplyDelete
  5. As soon as I found this internet site I went on reddit to share some of the love with them. اردو شاعری Naveed Ahmed

    ReplyDelete
  6. I gotta favorite this web site it seems very useful very beneficial 예스 카지노

    ---------------------------

    Hi my friend! I want to say that this article is amazing, nice written and include almost all important infos. I would like to see more posts like this . 더킹 카지노

    ReplyDelete
  7. Personally, I have found that to get just about the most fascinating topics if this draws a parallel to. android phone template

    ReplyDelete
  8. I think other site proprietors should take this web site as an model, very clean and great user friendly style and design, let alone the content. You’re an expert in this topic! 안전놀이터

    --------------------------------------------------------------------------------------------------------------------------------


    I believe that is among the most significant information for me. And i’m satisfied studying your article. But wanna observation on some normal things, The web site style is perfect, the articles is in point of fact excellent . Excellent task, cheers. 스포츠중계

    ReplyDelete
  9. Hi I am so delighted I found your blog page, I really found you by accident, while I was browsing on Yahoo for something else, Anyways I am here now and would just like to say cheers for a incredible post and a all round interesting blog (I also love the theme/design), I don’t have time to look over it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read more, Please do keep up the excellent job. https://royalcbd.com/product/cbd-oil-2500mg/

    ReplyDelete
  10. I appreciate your work , thanks for all the informative blog posts. 먹튀검증

    ReplyDelete
  11. Thank you, I’ve recently been searching for info about this subject for ages and yours is the best I’ve found so far. mlb중계


    -------------------------------------------------------

    thanx for such a fantastic website. Where else could someone get that kind of info written in such a perfect way? I have a presentation that I am presently working on, and I have been on the look out for such information. 해외스포츠중계

    ReplyDelete
  12. First, let’s kill off a genuine fabrication: You can not use a reverse cellular phone number lookup for totally free anywhere, anytime. top development companies

    ReplyDelete
  13. They are the public safety and security agency for the brokerage industry and they specialize in helping brokers adhere to all applicable rules and regulations as well as educating brokers on the laws. For more information about rules and regulation of mortgage loan, Maine FHA loan.

    ReplyDelete
  14. I really enjoy reading webdesign studios and also appreciate your work.

    ReplyDelete
  15. While its outside is certainly eye catching, the inside of the vessel is arguably just as impressive if recently released renderings for the design are anything to go by.
    https://www.betting33.com

    ReplyDelete
  16. Described as the "superstar area of the yacht," Escalade's huge saloon, which holds a mirrored ceiling, is split into two sections, with a kitchen on one side, and a lavish lounge area and a raised dining area on the other.
    https://www.syy577.com

    ReplyDelete
  17. In addition, the yacht has four en suite cabins, a large cinema screen, various sunbathing areas, an onboard garage with room for a tender boat and two jet skis, and a glass bottomed hot tub.
    https://www.dok222.com

    ReplyDelete
  18. While the Escalade concept hasn't been picked up by a shipyard as yet, Akalın, who has been working with Anwigema on the project since 2019, says they've received plenty of interest from potential buyers and he's confident it will be hitting the waters in the not too distant future.
    https://www.ccclub700.com

    ReplyDelete
  19. "She is the design that meets the needs of the modern world," he adds, explaining the project would take between six to 10 months to complete "with the right planning" once funding is secured.
    https://www.hgame75.com

    ReplyDelete
  20. laptops batteries

    HP Compaq Presario g62 Battery https://www.all-laptopbattery.com/hp-compaq-presario-g62.html
    HP Elitebook 8760w Battery https://www.all-laptopbattery.com/hp-elitebook-8760w.html
    HP Mini 3100 Battery https://www.all-laptopbattery.com/hp-mini-3100.html
    Akku Acer Aspire 7741z http://www.laptop-akkus.com/acer-aspire-7741z.html
    Akku Acer Aspire v3-771 http://www.laptop-akkus.com/acer-aspire-v3-771.html
    Akku Acer Gateway nv74 http://www.laptop-akkus.com/acer-gateway-nv74.html

    ReplyDelete
  21. I'm also visiting this site regularly, this web site is really nice and the users are genuinely sharing good thoughts.design firm la

    ReplyDelete
  22. Very informative post. Really looking forward to read more. Awesome.Pocket Option Review

    ReplyDelete
  23. PLAY NEW CASINO GAMES ONLINE:

    https://www.omgqq.com 우리카지노사이트
    https://www.omgqq.com/thekingcasino 더킹카지노
    https://www.omgqq.com/sandscasino 샌즈카지노
    https://www.omgqq.com/firstcasino 퍼스트카지노
    https://www.omgqq.com/yescasino 예스카지노
    https://www.omgqq.com/supercaisno 슈퍼카지노
    https://www.omgqq.com/gatsbycasino 개츠비카지노
    https://www.omgqq.com/33casino 33카지노
    https://www.omgqq.com/worldcasino 월드카지노
    https://www.omgqq.com/blog

    ReplyDelete
  24. https://www.all-laptopbattery.com/asus-g73s.html ASUS G73S Battery
    https://www.all-laptopbattery.com/ASUS-g71v.html ASUS G71V Battery
    https://www.all-laptopbattery.com/asus-a32-k55.html ASUS A32-K55 Battery
    http://www.laptop-akkus.com/hp-envy-14-sleekbook.html HP ENVY 14
    http://www.laptop-akkus.com/hp-elitebook-8530p.html HP EliteBook 8530p
    http://www.laptop-akkus.com/hp-envy-dv7-7000.html HP Envy DV7-7000

    ReplyDelete
  25. https://www.dnfl150.com/gatsby
    https://www.dnfl150.com/33casino
    https://www.dnfl150.com/ondasino
    https://www.dnfl150.com

    ReplyDelete
  26. https://www.ajp150.com/theking
    https://www.ajp150.com/sands
    https://www.ajp150.com/first
    https://www.ajp150.com/33casino
    https://www.ajp150.com/worldcasino
    https://www.ajp150.com/korea
    https://www.ajp150.com/

    ReplyDelete
  27. https://www.btlcasino.com 카지노사이트
    https://www.btlcasino.com/theking 더킹카지노
    https://www.btlcasino.com/sands 샌즈카지노
    https://www.btlcasino.com/first 퍼스트카지노
    https://www.btlcasino.com/yes 예스카지노
    https://www.btlcasino.com/super 슈퍼카지노
    https://www.btlcasino.com/gatsby 개츠비카지노
    https://www.btlcasino.com/33 33카지노

    ReplyDelete
  28. In spite of its recognized significance, the message is frequently the most disregarded and belittled part of a showcasing correspondences crusade. Once made, it's only sometimes examined. whats mod apks

    ReplyDelete