wenbronk commented on issue #3682: URL: https://github.com/apache/incubator-doris/issues/3682#issuecomment-634477366
> `手动抛出异常`是指什么? 抛出异常, 终止事务, 让producer开启的事务不能正常提交. ```java Properties kafkaProperties = new Properties(); kafkaProperties.put("acks", "all"); kafkaProperties.put("retries", 3); kafkaProperties.put("batch.size", 3000); kafkaProperties.put("linger.ms", 10); kafkaProperties.put("buffer.memory", 33554432); kafkaProperties.put("bootstrap.servers", "10.14xxx.9:9092"); kafkaProperties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); kafkaProperties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); kafkaProperties.put("transactional.id", "send_20200522" + increment.getAndIncrement()); kafkaProperties.put("enable.idempotence", true); KafkaProducer<String, Object> producer = new KafkaProducer<>(kafkaProperties); try { producer.initTransactions(); producer.beginTransaction(); String data = getData(); ProducerRecord<String, Object> record = new ProducerRecord<>(topic, data); Future<RecordMetadata> future = producer.send(record); producer.flush(); future.get(); int a = 1/0; producer.commitTransaction(); } catch (Exception e) { producer.abortTransaction(); e.printStackTrace(); } finally { producer.close(); } ``` 这个是测试发送的客户端, 在 int a = 1/0 处抛出异常, 终止事务 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org