Home > Back-end >  No resolvable bootstrap urls are given in the bootstrap. The servers
No resolvable bootstrap urls are given in the bootstrap. The servers

Time:09-19

On the virtual machine has launched a KAFKA consumers used to receive messages,

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 Producer=new KafkaProducer (properties);
ProducerRecord ProducerRecord=new ProducerRecord (topic, "kafka - demo", "hello, kafka");
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
  • Related