private void asyncSend(KafkaProducer<Integer, String> producer, int key, String value) {
        // send the record asynchronously, setting a callback to be notified of the result
        // note that, even if you set a small batch.size with linger.ms=0, the send operation
        // will still be blocked when buffer.memory is full or metadata are not available
        producer.send(new ProducerRecord<>(topic, key, value), new ProducerCallback(key, value));
    }
A simple producer thread supporting two send modes:
- Async mode (default): records are sent without waiting for the response.
- Sync mode: each send operation blocks waiting for the response.
examples/src/main/java/kafka/examples/Producer.java