to answer the original question: using groupId helps to avoid the situation of "re-consuming all messages from the beginning of time"
if you change groupId, you will receive all messages from the moment the queue was created (or from the moment of the last data cleaning based on the kafka log storage policy)
do not confuse this with the kafka-console-consumer "--from-begin" flag (which sets the auto.offset.reset parameter), which can be chosen between options 1 and 2 below:
1) consume new messages from the moment the last message was destroyed (NOT from the beginning of the time when the Kafka queue was created):
props.put ("auto.offset.reset", "small");
2) consume new messages from the moment the subscriber starts the JVM (in this case, you risk losing messages placed in the queue when the subscriber is not working and does not listen to the queue):
props.put ("auto.offset.reset", "largest");
side of note: below is only related to the original question
for a more advanced use case - if you are trying to programmatically set a consumer offset for playing messages starting at a specific time, you will need to use the SimpleConsumer API, as shown in https://cwiki.apache.org/confluence/display/KAFKA/0.8. 0 + SimpleConsumer + Example to find the smallest offset to play from the right broker / section. Which essentially replaces zookeeper with our own FindLeader logic. very difficult.
for this use case (ad-hoc repetition of messages starting from a specific user time), we decided to keep the local message cache and manage local offsets instead of using the kafka offset management api (which would require re-implementing a good piece of zookeeper functionality with SimpleConsumer).
those. treat kafka as a "postman", as soon as the message is delivered, it is sent to the local mailbox, and in case we need to return to a certain offset in the past and, say, play messages (which have already been used), for example. in the event of a consumer application error, we do not return to the "post office" (Kafka brokers) to find out the correct delivery of the order, but manage it locally .
end note side