标签:except kafka exception shm trie ++ produce sock interrupt
public class KafkaProducerDemo { public static void main(String[] args) throws InterruptedException { /* Properties props = new Properties(); * props.put("bootstrap.servers", "localhost: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"); */ Map<String, Object> config = new HashMap<String, Object>(); config.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); config.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); config.put("bootstrap.servers", "m2:9092"); Producer<String, String> producer = new KafkaProducer<String, String>(config); // 发送业务消息 // 读取文件 读取内存数据库 读socket端口 for (int i = 1; i <= 100; i++) { Thread.sleep(500); producer.send(new ProducerRecord<String, String>("test2", i + "")); } } }
标签:except kafka exception shm trie ++ produce sock interrupt
原文地址:http://www.cnblogs.com/heml/p/6074294.html