标签:ack util memory err key rgs cat static ica
package cn.xiaojf.kafka.producer; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.Producer; import org.apache.kafka.clients.producer.ProducerRecord; import java.util.Properties; /** * Created by 肖建锋 on 2017/3/22. */ public class MsgProducer2 { public static void main(String[] args) { Properties props = new Properties(); props.put("bootstrap.servers", "192.168.59.130:9092,192.168.59.131:9092,192.168.59.132:9092"); props.put("acks", "all"); props.put("retries ", 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"); Producer<String, String> producer = new KafkaProducer(props); for(int i = 0; i < 100; i++) producer.send(new ProducerRecord<String, String>("my-replicated-topic", Integer.toString(i), Integer.toString(i))); producer.close(); } }
<dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>0.10.2.0</version> </dependency>
标签:ack util memory err key rgs cat static ica
原文地址:http://www.cnblogs.com/xiaojf/p/6602695.html