package com.lyzx.kafka;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.KafkaException;
import org.apache.kafka.common.errors.AuthorizationException;
import org.apache.kafka.common.errors.OutOfOrderSequenceException;
import org.apache.kafka.common.errors.ProducerFencedException;
import org.apache.kafka.common.serialization.StringSerializer;
import org.junit.Test;
import java.util.Properties;
/**
* A Kafka client that publishes records to the Kafka cluster.
* The producer is thread safe and sharing a single producer
* instance across threads will generally be faster than having multiple instances
*
* kafka客户端用于发送消息到kafka集群
* producer线程安全,多个线程共享时效率好于每个线程一个producer
*/
public class ProducerTest {
private static String ips = "192.168.29.164:9092";
/**
* produc
《Kafka实战》之生产者API使用(参数解释超详细)
最新推荐文章于 2024-10-10 07:30:00 发布
本文详细解析了Kafka的生产者API使用,重点探讨了各种关键参数的含义与设置,帮助读者深入理解如何优化Kafka消息发布过程。
摘要由CSDN通过智能技术生成