8000 Polish "Add support for arbitrary producer/consumer Kafka properties" · spring-projects/spring-boot@38ad582 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38ad582

Browse files
committed
Polish "Add support for arbitrary producer/consumer Kafka properties"
Closes gh-9775
1 parent 191752d commit 38ad582

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class KafkaProperties {
6666
* Additional properties, common to producers and consumers, used to configure the< 8000 /div>
6767
* client.
6868
*/
69-
private Map<String, String> properties = new HashMap<>();
69+
private final Map<String, String> properties = new HashMap<>();
7070

7171
private final Consumer consumer = new Consumer();
7272

@@ -100,10 +100,6 @@ public Map<String, String> getProperties() {
100100
return this.properties;
101101
}
102102

103-
public void setProperties(Map<String, String> properties) {
104-
this.properties = properties;
105-
}
106-
107103
public Consumer getConsumer() {
108104
return this.consumer;
109105
}
@@ -270,9 +266,9 @@ public static class Consumer {
270266
private Integer maxPollRecords;
271267

272268
/**
273-
* Additional properties used to configure the client.
269+
* Additional consumer-specific properties used to configure the client.
274270
*/
275-
private Map<String, String> properties = new HashMap<>();
271+
private final Map<String, String> properties = new HashMap<>();
276272

277273
public Ssl getSsl() {
278274
return this.ssl;
@@ -378,10 +374,6 @@ public Map<String, String> getProperties() {
378374
return this.properties;
379375
}
380376

381-
public void setProperties(Map<String, String> properties) {
382-
this.properties = properties;
383-
}
384-
385377
public Map<String, Object> buildProperties() {
386378
Map<String, Object> properties = new HashMap<>();
387379
if (this.autoCommitInterval != null) {
@@ -508,9 +500,9 @@ public static class Producer {
508500
private Integer retries;
509501

510502
/**
511-
* Additional properties used to configure the client.
503+
* Additional producer-specific properties used to configure the client.
512504
*/
513-
private Map<String, String> properties = new HashMap<>();
505+
private final Map<String, String> properties = new HashMap<>();
514506

515507
public Ssl getSsl() {
516508
return this.ssl;
@@ -592,10 +584,6 @@ public Map<String, String> getProperties() {
592584
return this.properties;
593585
}
594586

595-
public void setProperties(Map<String, String> properties) {
596-
this.properties = properties;
597-
}
598-
599587
public Map<String, Object> buildProperties() {
600588
Map<String, Object> properties = new HashMap<>();
601589
if (this.acks != null) {

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ content into your application; rather pick only the properties that you need.
968968
spring.kafka.consumer.heartbeat-interval= # Expected time in milliseconds between heartbeats to the consumer coordinator.
969969
spring.kafka.consumer.key-deserializer= # Deserializer class for keys.
970970
spring.kafka.consumer.max-poll-records= # Maximum number of records returned in a single call to poll().
971-
spring.kafka.consumer.properties.*= # Additional properties used to configure the client.
971+
spring.kafka.consumer.properties.*= # Additional consumer-specific properties used to configure the client.
972972
spring.kafka.consumer.ssl.key-password= # Password of the private key in the key store file.
973973
spring.kafka.consumer.ssl.keystore-location= # Location of the key store file.
974974
spring.kafka.consumer.ssl.keystore-password= # Store password for the key store file.
@@ -992,7 +992,7 @@ content into your application; rather pick only the properties that you need.
992992
spring.kafka.producer.client-id= # Id to pass to the server when making requests; used for server-side logging.
993993
spring.kafka.producer.compression-type= # Compression type for all data generated by the producer.
994994
spring.kafka.producer.key-serializer= # Serializer class for keys.
995-
spring.kafka.producer.properties.*= # Additional properties used to configure the client.
995+
spring.kafka.producer.properties.*= # Additional producer-specific properties used to configure the client.
996996
spring.kafka.producer.retries= # When greater than zero, enables retrying of failed sends.
997997
spring.kafka.producer.ssl.key-password= # Password of the private key in the key store file.
998998
spring.kafka.producer.ssl.keystore-location= # Location of the key store file.

spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5121,9 +5121,12 @@ are not directly supported, use the following:
51215121
spring,kafka.producer.properties.baz.qux=fiz
51225122
----
51235123

5124-
This sets the common `foo.bar` Kafka property to `baz` (applies to both producers and consumers), the consumer `fiz.buz` property to `qux` and the `baz.qux` producer property to `fiz`.
5124+
This sets the common `foo.bar` Kafka property to `baz` (applies to both producers and
5125+
consumers), the consumer `fiz.buz` property to `qux` and the `baz.qux` producer property
5126+
to `fiz`.
51255127

5126-
IMPORTANT: Properties set in this way will override properties that are in the subset that boot explicitly supports.
5128+
IMPORTANT: Properties set in this way will override any configuration item that Spring
5129+
Boot explicitly supports.
51275130

51285131
[[boot-features-resttemplate]]
51295132
== Calling REST services with '`RestTemplate`'

0 commit comments

Comments
 (0)
0