sayantanu-dey commented on code in PR #12035: URL: https://github.com/apache/kafka/pull/12035#discussion_r854734261
########## streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java: ########## @@ -1498,6 +1516,37 @@ public synchronized boolean close(final Duration timeout) throws IllegalArgument return close(timeoutMs); } + /** + * Shutdown this {@code KafkaStreams} by signaling all the threads to stop, and then wait up to the timeout for the + * threads to join. + * @param options contains timeout to specify how long to wait for the threads to shutdown, and a flag leaveGroup to + * trigger consumer leave call + * @return {@code true} if all threads were successfully stopped—{@code false} if the timeout was reached + * before all threads stopped + * Note that this method must not be called in the {@link StateListener#onChange(KafkaStreams.State, KafkaStreams.State)} callback of {@link StateListener}. + * @throws IllegalArgumentException if {@code timeout} can't be represented as {@code long milliseconds} + */ + public synchronized boolean close(final CloseOptions options) throws IllegalArgumentException { + final String msgPrefix = prepareMillisCheckFailMsgPrefix(options.timeout, "timeout"); + final long timeoutMs = validateMillisecondDuration(options.timeout, msgPrefix); + if (timeoutMs < 0) { + throw new IllegalArgumentException("Timeout can't be negative."); + } + + if (options.leaveGroup) { + log.debug("Sending leave group trigger to removing instance from consumer group"); + //removing instance from consumer group + adminClient.removeMembersFromConsumerGroup( Review Comment: if we do so, then should we pass the same `timeoutMs` to the close function? or should we subtract the time taken by the future to get resolved? Meanwhile, I didn’t add a wait for the future to get resolved, as I thought that if the call resolves then it would be removed from the consumer group and, if the call rejects or returns failure then after `session.timeout` the instance will be anyway removed from the group. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org