Integration / Apache Kafka Interview questions
What is a Kafka producer?
A producer is the client application that publishes (writes) records to one or more Kafka topics. It's responsible for serializing the record's key and value, deciding (directly or via a partitioner) which partition a record goes to, batching records for efficiency, and handling the broker's acknowledgment according to its configured durability guarantee.
Properties props = new Properties(); props.put("bootstrap.servers", "localhost:9092"); props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); KafkaProducer<String, String> producer = new KafkaProducer<>(props); producer.send(new ProducerRecord<>("orders", "order-123", "{\"status\":\"created\"}")); producer.close();
A key producer setting is acks, which controls how much durability the producer waits for before considering a send successful — acks=0 (fire and forget), acks=1 (leader only), or acks=all (the full in-sync replica set), trading off latency against the risk of data loss on a broker failure.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
