Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add consumer group to message in java?

I'm new in java, spring and kafka
I have the next code for sending message

kafkaTemplate.send(topic, message);

My configuration for producer:

 props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,
            bootstrapServers);
    props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
            IntegerSerializer.class);
    props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
            StringSerializer.class);
    // value to block, after which it will throw a TimeoutException
    props.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 5000);

I want to send message with my consumer group (example "MyConsumerGroup"),
but I don't know how I can to do it thanks for help

like image 764
pasha Avatar asked Jan 26 '17 09:01

pasha


1 Answers

The concept of "consumer groups" only applies to consumers (as the name suggest). If you write a message to Kafka, any consumer group can read the message later on.

Thus, if you write a message, specifying a consumer group is not possible because it would not make any sense.

like image 65
Matthias J. Sax Avatar answered Sep 28 '22 09:09

Matthias J. Sax