kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BYEONG-GI KIM <bg...@bluedigm.com>
Subject Kafka 0.9 producer doesn't work
Date Wed, 20 Jan 2016 07:56:55 GMT

I set up the Kafka testbed environment on my VirtualBox, which simply has a
Kafka broker.

I tested the simple consumer & producer scripts, aka
kafka-console-consumer.sh and bin/kafka-console-producer.sh respectively,
and both of them worked fine. I could see the output from the consumer side
whenever typing any words on the producer.

After that, I moved to test a simple java kafka producer/consumer. I copied
and pasted the example source code for producer from
and yeah, unfortunately, it seems not working well; no output was printed
by the above consumer script. There was even no error log on Eclipse.

I really don't know what the problem is... I think that the properties for
both zookeeper and kafka seems fine, since the example scripts worked well,
at least.

I attached my tested source code:
 import java.util.Properties;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.KafkaException;
import org.apache.kafka.common.errors.TimeoutException;

public class ProducerExample {
public static void main(String[] args) throws Exception, TimeoutException,
KafkaException {
Properties props = new Properties();
props.put("bootstrap.servers", "");
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
// props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);

Producer<String, String> producer = new KafkaProducer<String,

try {
for (int i = 0; i < 10; i++) {
producer.send(new ProducerRecord<String, String>("test", 0,
Integer.toString(i), Integer.toString(i)));
} catch (TimeoutException te) {
} catch (Exception ke) {


Any advice would really be helpful. Thanks in advance.

Best regards


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message