In local wrote a producer demo kafka on sending messages to the virtual machine, an error No resolvable bootstrap urls given in the bootstrap. The servers,
Port of the virtual machine, what firewalls are already open,
Kafka using the default configuration, only changed the log path,
First time studying kafka, bosses, please give directions. The following is a Java code:
Private static final String brokerlist="192.168.1.5:9092";
Private static final String topic="heima";
Properties properties=new Properties();
//set the key serializer
Properties. The put (" key. The serializer ", "org.apache.kafka.com mon. Serialization. StringSerializer");
//set retries
The properties. The put (ProducerConfig RETRIES_CONFIG, 10);
//setting the serializer
Properties. The put (" value. The serializer ", "org.apache.kafka.com mon. Serialization. StringSerializer");
//set up the cluster address
The properties, the put (" the bootstrap. The servers, "brokerlist);
KafkaProducer
ProducerRecord
Try {
Producer. The send (producerRecord);
{} the catch (Exception ex)
ex.printStackTrace();
} the finally {
Producer. The close ();
}
CodePudding user response:
https://blog.csdn.net/qq_36811160/article/details/102765681 this should help to you