首先,我们需要在Kafka配置文件(server.properties)中进行以下更改: listeners=SASL_PLAINTEXT://:9092security.inter.broker.protocol=SASL_PLAINTEXTsasl.mechanism.inter.broker.protocol=PLAINsasl.enabled.mechanisms=PLAINsasl.jaas.con
importorg.apache.kafka.clients.producer.*;importjava.util.Properties;publicclassKafkaProducerExample{publicstaticvoidmain(String[]args){Propertiesprops=newProperties();props.put("bootstrap.servers","your_hostname:9092");props.put("security.protocol","SASL_PLAINTEXT");props.put("sasl.mechanism","PLAI...
Producer<String, String> producer = new KafkaProducer<>(props); //Synchronized Mode, Producer will wait and block until Kafka Server return response try{ Future future =producer.send(new ProducerRecord<>("CRM_Contract", contractId, payload));// (topic, key, payload),the second parameter is ...
partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner receive.buffer.bytes = 32768 reconnect.backoff.max.ms = 1000 reconnect.backoff.ms = 50 request.timeout.ms = 30000 retries = 0 retry.backoff.ms = 100 sasl.jaas.config = null sasl.kerberos.kinit.cmd = /...
kafka: bootstrap-servers: 10.xx.67.10:9092 consumer: #判断是队列模式还是发布订阅模式 group-id: force #producer将试图批处理消息记录,以减少请求次数。 batch-size: 16384 retries: 0 buffer-memory: 33554432 enable-auto-commit: true auto-commit-interval: 1000 #latest:自动复位offset为最新 auto-offset...
三、kafka生产者程序 importorg.apache.kafka.clients.producer.KafkaProducer;importorg.apache.kafka.clients.producer.ProducerRecord;importorg.apache.kafka.clients.producer.RecordMetadata;importjava.util.Properties;importjava.util.concurrent.ExecutionException;publicclassMyProducer {privatefinalstaticString TOPIC_NAME...
KafkaProducer<String, String> producer = new KafkaProducer<>(props);我遇到了错误:org.apache.kafka.common.KafkaException: javax.security.auth.login.LoginException: unable to find LoginModule class: org.apache.kafka.common.security.scram.ScramLoginModule at org.apache.kafka.common.network.SaslChannel...
sasl.enabled.mechanisms=PLAIN kafka_server_jaas.conf 这个是新增文件 KafkaServer { org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="xxxxxx" user_admin="xxxxxx"; }; 最后就是kafka的启动脚本加了一句 : ...
如果是默认接入点实例,该参数不需要配置;如果是SSL接入点实例或者SASL接入点实例,该参数必须配置。 发送消息 编译并运行KafkaProducerDemo.java发送消息。 示例代码 订阅消息 选择以下任意一种方式订阅消息。 单Consumer订阅消息:编译并运行KafkaConsumerDemo.java发送消息。 示例代码 多Consumer订阅消息:编译并运行Kafka...
sasl.jaas.config=/var/lib/kafka/config/kafka_jaas.conf 在启动zookeeper和kafka之后,我得到了以下例外java.lang.illegalargumentexception:要求失败:inter.broker.listener.name必须是在Adverted.listeners中定义的侦听器名称。基于当前配置的侦听器的有效选项是纯文本java.lang.illegalargumentexception:requirement failed:...