Skip to content

GH-3116: Upgrade kafka-client to 3.7.0 #3117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ext {
jaywayJsonPathVersion = '2.8.0'
junit4Version = '4.13.2'
junitJupiterVersion = '5.10.2'
kafkaVersion = '3.6.1'
kafkaVersion = '3.7.0'
kotlinCoroutinesVersion = '1.7.3'
log4jVersion = '2.22.1'
micrometerDocsVersion = '1.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
This section covers the changes made from version 3.1 to version 3.2.
For changes in earlier version, see xref:appendix/change-history.adoc[Change History].

[[x32-kafka-client-version]]
=== Kafka Client Version

This version requires 3.7.0 `kafka-clients`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t we have anywhere else in docs the mentioning for Kafka Client compatibility ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compatibility matrix is on the project page, which we need to edit later, maybe once this is merged.


[[x32-kafka-streams-iqs-support]]
=== Kafka Streams Interactive Query Support

A new API `KafkaStreamsInteractiveQuerySupport` for accessing queryable stores used in Kafka Streams interactive queries.
See xref:streams.adoc#kafka-streams-iq-support[Kafka Streams Interactive Support] for more details.



[[x32-tiss]]
=== TransactionIdSuffixStrategy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.kafka.common.MetricName;
import org.apache.kafka.common.PartitionInfo;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.Uuid;
import org.apache.kafka.common.errors.OutOfOrderSequenceException;
import org.apache.kafka.common.errors.ProducerFencedException;
import org.apache.kafka.common.errors.TimeoutException;
Expand All @@ -67,6 +68,8 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;



/**
* The {@link ProducerFactory} implementation for a {@code singleton} shared {@link Producer} instance.
* <p>
Expand Down Expand Up @@ -113,6 +116,7 @@
* @author Chris Gilbert
* @author Thomas Strauß
* @author Adrian Gygax
* @author Soby Chacko
*/
public class DefaultKafkaProducerFactory<K, V> extends KafkaResourceFactory
implements ProducerFactory<K, V>, ApplicationContextAware,
Expand Down Expand Up @@ -1128,6 +1132,11 @@ public List<PartitionInfo> partitionsFor(String topic) {
return this.delegate.metrics();
}

@Override
public Uuid clientInstanceId(Duration timeout) {
return this.delegate.clientInstanceId(timeout);
}

@Override
public void initTransactions() {
this.delegate.initTransactions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,14 @@ public void manyTests() throws Exception {
"listenerConsumer.consumer"));
assertThat(
KafkaTestUtils.getPropertyValue(this.listener.listen4Consumer,
"fetcher.fetchConfig.maxPollRecords", Integer.class))
"delegate.fetcher.fetchConfig.maxPollRecords", Integer.class))
.isEqualTo(100);
assertThat(this.quxGroup).hasSize(1);
assertThat(this.quxGroup.get(0)).isSameAs(manualContainer);
List<?> containers = KafkaTestUtils.getPropertyValue(manualContainer, "containers", List.class);
assertThat(KafkaTestUtils.getPropertyValue(containers.get(0), "listenerConsumer.consumerGroupId"))
.isEqualTo("qux");
assertThat(KafkaTestUtils.getPropertyValue(containers.get(0), "listenerConsumer.consumer.clientId"))
assertThat(KafkaTestUtils.getPropertyValue(containers.get(0), "listenerConsumer.consumer.delegate.clientId"))
.isEqualTo("clientIdViaProps3-0");

template.send("annotated4", 0, "foo");
Expand All @@ -371,15 +371,15 @@ public void manyTests() throws Exception {
TopicPartitionOffset[].class)[3];
assertThat(offset.isRelativeToCurrent()).isTrue();
assertThat(KafkaTestUtils.getPropertyValue(fizContainer,
"listenerConsumer.consumer.groupId", Optional.class).get())
"listenerConsumer.consumer.delegate.groupId", Optional.class).get())
.isEqualTo("fiz");
assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.clientId"))
assertThat(KafkaTestUtils.getPropertyValue(fizContainer, "listenerConsumer.consumer.delegate.clientId"))
.isEqualTo("clientIdViaAnnotation-0");
assertThat(KafkaTestUtils.getPropertyValue(fizContainer,
"listenerConsumer.consumer.fetcher.fetchConfig.maxPollRecords"))
"listenerConsumer.consumer.delegate.fetcher.fetchConfig.maxPollRecords"))
.isEqualTo(10);
assertThat(KafkaTestUtils.getPropertyValue(fizContainer,
"listenerConsumer.consumer.fetcher.fetchConfig.minBytes"))
"listenerConsumer.consumer.delegate.fetcher.fetchConfig.minBytes"))
.isEqualTo(420000);

MessageListenerContainer rebalanceConcurrentContainer = registry.getListenerContainer("rebalanceListener");
Expand All @@ -402,9 +402,9 @@ public void manyTests() throws Exception {

MessageListenerContainer rebalanceContainer = (MessageListenerContainer) KafkaTestUtils
.getPropertyValue(rebalanceConcurrentContainer, "containers", List.class).get(0);
assertThat(KafkaTestUtils.getPropertyValue(rebalanceContainer, "listenerConsumer.consumer.groupId"))
assertThat(KafkaTestUtils.getPropertyValue(rebalanceContainer, "listenerConsumer.consumer.delegate.groupId"))
.isNotEqualTo("rebalanceListener");
String clientId = KafkaTestUtils.getPropertyValue(rebalanceContainer, "listenerConsumer.consumer.clientId",
String clientId = KafkaTestUtils.getPropertyValue(rebalanceContainer, "listenerConsumer.consumer.delegate.clientId",
String.class);
assertThat(clientId).startsWith("rebal-");
assertThat(clientId.indexOf('-')).isEqualTo(clientId.lastIndexOf('-'));
Expand Down Expand Up @@ -535,13 +535,13 @@ public void testJson() throws Exception {
MessageListenerContainer buzContainer = (MessageListenerContainer) KafkaTestUtils
.getPropertyValue(buzConcurrentContainer, "containers", List.class).get(0);
assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
"listenerConsumer.consumer.groupId", Optional.class).get())
"listenerConsumer.consumer.delegate.groupId", Optional.class).get())
.isEqualTo("buz.explicitGroupId");
assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
"listenerConsumer.consumer.fetcher.fetchConfig.maxPollRecords"))
"listenerConsumer.consumer.delegate.fetcher.fetchConfig.maxPollRecords"))
.isEqualTo(5);
assertThat(KafkaTestUtils.getPropertyValue(buzContainer,
"listenerConsumer.consumer.fetcher.fetchConfig.minBytes"))
"listenerConsumer.consumer.delegate.fetcher.fetchConfig.minBytes"))
.isEqualTo(123456);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import java.time.Duration;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -64,6 +65,7 @@
* @author Chris Gilbert
* @author Artem Bilan
* @author Adrian Gygax
* @author Soby Chacko
*
* @since 1.0.6
*/
Expand Down Expand Up @@ -484,7 +486,7 @@ public void consumerRemoved(String id, Consumer consumer) {
assertThat(adds).hasSize(1);
assertThat(adds.get(0)).isEqualTo("cf.foo-0");
assertThat(removals).hasSize(0);
consumer.close();
consumer.close(Duration.ofSeconds(10));
assertThat(removals).hasSize(1);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,6 +67,7 @@
import org.springframework.kafka.test.context.EmbeddedKafka;
import org.springframework.kafka.test.utils.ContainerTestUtils;
import org.springframework.kafka.test.utils.KafkaTestUtils;
import org.springframework.lang.Nullable;

/**
* @author Gary Russell
Expand All @@ -75,6 +76,7 @@
* @author Marius Bogoevici
* @author Artem Yakshin
* @author Vladimir Tsanev
* @author Soby Chacko
*/
@EmbeddedKafka(topics = { ConcurrentMessageListenerContainerTests.topic1,
ConcurrentMessageListenerContainerTests.topic2,
Expand Down Expand Up @@ -230,13 +232,13 @@ public void testAutoCommitWithRebalanceListener() throws Exception {
DefaultKafkaConsumerFactory<Integer, String> cf = new DefaultKafkaConsumerFactory<Integer, String>(props) {

@Override
protected Consumer<Integer, String> createKafkaConsumer(String groupId, String clientIdPrefix,
String clientIdSuffixArg, Properties properties) {
protected Consumer<Integer, String> createKafkaConsumer(@Nullable String groupId, @Nullable String clientIdPrefix,
@Nullable String clientIdSuffixArg, @Nullable Properties properties) {

overrides.set(properties);
Consumer<Integer, String> created = super.createKafkaConsumer(groupId, clientIdPrefix,
clientIdSuffixArg, properties);
assertThat(KafkaTestUtils.getPropertyValue(created, "requestTimeoutMs", Long.class)).isEqualTo(23000L);
assertThat(KafkaTestUtils.getPropertyValue(created, "delegate.requestTimeoutMs", Integer.class)).isEqualTo(23000);
return created;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors.
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,7 +63,8 @@ void configurePreLoadedDelegates() {
props.setMessageListener(mock(MessageListener.class));
KafkaMessageListenerContainer<String, Object> container = new KafkaMessageListenerContainer<>(cFact, props);
container.start();
assertThat(KafkaTestUtils.getPropertyValue(container, "listenerConsumer.consumer.valueDeserializer"))
assertThat(KafkaTestUtils.getPropertyValue(container,
"listenerConsumer.consumer.delegate.deserializers.valueDeserializer"))
.isSameAs(delegating);
Map<?, ?> delegates = KafkaTestUtils.getPropertyValue(delegating, "delegates", Map.class);
assertThat(delegates).hasSize(1);
Expand Down