Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

build test deploy Maven Central


Integration of Kafka client and Kafka streams for Bootique. See usage examples:


Include the BOMs and then bootique-kafka-client:


<!-- If using Producer and/or Consumer -->

<!-- If using streams -->

Producer/Consumer Configuration

Configure parameters in the YAML. Note that practically all of these settings can be overidden when obtaining a specific Producer or Consumer instance via io.bootique.kafka.client.KafkaClientFactory. So this is just a collection of defaults for the most typical Producer or Consumer:

  # any number of named clusters, specifying comma-separated bootstrap Kafka servers for each.
    cluster2: host1:9092,host2:9092
    autoCommit: true
    autoCommitInterval: "200ms"
    defaultGroup: myappgroup
    sessionTimeout: "2s"
    acks: all # values are "all" or numeric number for min acks
    retries: 1
    batchSize: 16384
    linger: "1ms"
    bufferMemory: 33554432

Now you can inject producer and consumer factories and create any number of producers and consumers. Producer example (also see this code sample) :

KafkaProducerFactory factory;

public void runProducer() {

    Producer<byte[], String> producer = factory

    producer.send(new ProducerRecord<>("mytopic", "Hi!"));

    // close if there's nothing else to send

Consumer example (also see this code sample) :

KafkaConsumerFactory factory;

public void runConsumer() {
    // this will start consumer in the background
    KafkaPollingTracker poll = factory
        // configure consumer
        // start consumption in the background
        .consume((c, data) -> data.forEach(
                r -> System.out.println(r.topic() + "_" + r.offset() + ": " + r.value())));
    // Close when we need to stop consumption. With no explicit Bootique will
    // close the consumer before the app exit
    // poll.close();

Streams Configuration