Reputation: 1449
I set up Apache Kafka 0.8.2.1 in a CentOS environment, created a topic and sent / received some dummy messages via the command line producer / consumer.
As you can see in the screenshot that worked well. No I'm writing a custom producer to get my messages from Java to the topic.
package de.jofre.kafka;
import java.util.Properties;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;
public class TestProducer {
public static void main(String[] args) {
Properties props = new Properties();
props.put("bootstrap.servers", "192.168.145.130:9092");
props.put("key.serializer", StringSerializer.class.getName());
props.put("value.serializer", StringSerializer.class.getName());
KafkaProducer<String, String> prod = new KafkaProducer<String, String>(props);
ProducerRecord<String, String> record = new ProducerRecord<String, String>("test", "Kafka is great");
prod.send(record);
prod.close();
}
}
Calling the shown main does not result into a message on the Kafka topic nor does it print any error message.
Does anybody have an idea why the message does not arrive in my topic?
Upvotes: 0
Views: 823
Reputation: 1449
Thanks to morganw09dev I found the answer. I tested with the dependencies org.apache.kafka kafka_2.11 0.8.2.1 and org.apache.kafka kafka-clients 0.8.2.1. Non of them worked.
The dependency that actually worked is org.apache.kafka kafka_2.10 0.8.2.1. I consider this to be a bug since I downloaded and run the kafka_2.11 binaries.
Upvotes: 1