Created 10-06-2016 06:34 AM
I'm using HDP 2.3.4 with kafka 0.9
The kafka console producer/consumer worked well, but when I tried to create a simple kafka producer using scala in windows, it went into exception with error description in subject. Scala code was some sample code from git, as below:
object ProducerExample extends App { import java.util.Properties import org.apache.kafka.clients.producer._ val props = new Properties() props.put("bootstrap.servers", "serverX:6667") props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer") props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer") props.put("security.protocol", "SASL_PLAINTEXT") val producer = new KafkaProducer[String, String](props) val TOPIC="test" for(i<- 1 to 50){ val record = new ProducerRecord(TOPIC, "key", s"hello $i") producer.send(record) } val record = new ProducerRecord(TOPIC, "key", "the end "+new java.util.Date) producer.send(record) producer.close() }
I'm pretty sure the bootstrap.servers setting is correct, as the console producer/consumer works with the same value.
Any comments/clues? thanks a lot!
Created 10-06-2016 07:10 AM
Kafka is installed on a linux box, tested console producer/consumer in the same linux box
Created 10-06-2016 01:18 PM
looks like your host name is not getting resolved. Pl check your host name. Also enable producer logs for more info.