public static void main(String[] args) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "localhost:9092");
//        props.put("acks", "0");

        // Reduce the time blocked when the broker is not available.
        props.put("max.block.ms", 100);

        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

        KafkaProducer<String, String> kafkaProducer = new KafkaProducer<>(props);

        LOGGER.info("Sending records");
        final List<Future<RecordMetadata>> futures = IntStream.rangeClosed(1, 10)
                .boxed()
                .map(i -> {
                    ProducerRecord<String, String> producerRecord = new ProducerRecord<>(
                            "sourceTopic", "key" + i, Instant.now().toString());

                    final Future<RecordMetadata> sendFuture = kafkaProducer.send(
                            producerRecord,
                            (metadata, exception) ->
                                    LOGGER.info("Callback called, {}, {}", metadata, exception));

                    LOGGER.info("Sent record {} (to producer)", i);
                    return sendFuture;
                })
                .collect(Collectors.toList());
        LOGGER.info("Sent all records} (to producer)");

//        Thread.sleep(1_000);

        LOGGER.info("Getting futures");
        futures.forEach(recordMetadataFuture -> {
            try {
                recordMetadataFuture.get();
            } catch (InterruptedException | ExecutionException e) {
                throw new RuntimeException(e);
            }
        });
        LOGGER.info("Future completed");

        LOGGER.info("Closing producer");
        kafkaProducer.close();
        LOGGER.info("Producer closed");
    }
Not a test as such, just a means to evaluate different kafka producer config
settings.
stroom-statistics/stroom-statistics-impl-hbase/src/test/java/stroom/statistics/impl/hbase/internal/TestKafkaProducerAsync.java