我正在尝试简单的Kafkapoc与样品生产者和消费者。消息发送自 console-producer
接收时间 console-consumer
,但消息来自 java kafka-clients producer
未在收到 console-consumer
. 以下是可复制的,
kafka queue version : 2.6.0
kafka-clients version : 2.6.0
java生产商:
public static void main(String[] args) {
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");
Producer<String, String> producer = new KafkaProducer(props);
try {
producer.send(new ProducerRecord<String, String>("enricher-co", "POC Message"));
} catch (Exception e) {
throw e;
} finally {
producer.close();
}
}
kafka队列设置是按照https://kafka.apache.org/quickstart .
这就是控制台的工作,控制台生产者,
$./bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic enricher-co
> Console POC
控制台耗电元件,
$./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic enricher-co
Console POC
请帮忙。
暂无答案!
目前还没有任何答案,快来回答吧!