上传jar包
设置前置脚本
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import java.util.Properties;// Kafka 生产者配置
Properties props = new Properties();
props.put("bootstrap.servers", "10.86.132.193:9092");
// props.put("acks", "all");
// props.put("retries", 0);
// props.put("batch.size", 16384);
// props.put("linger.ms", 1);
// props.put("buffer.memory", 33554432);
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
KafkaProducer producer = new KafkaProducer(props);
String topic = "oa-work-flow";String meaasge ="{\"logId\":1760560}";
// producer.send(new ProducerRecord(topic, "DLZ自动化测试your-message"));
producer.send(new ProducerRecord(topic, meaasge));
log.info("发送kafka消息成功");
producer.close();
查看kfaka发送的消息,验证成功