Polish Kafka properties

Closes gh-7672
This commit is contained in:
Phillip Webb
2016-12-20 18:14:14 -08:00
parent bdda470305
commit 1f7b3cad45
4 changed files with 48 additions and 45 deletions

View File

@@ -4646,9 +4646,12 @@ Only a subset of the properties supported by Kafka are available via the `KafkaP
class. If you wish to configure the producer or consumer with additional properties that
are not directly supported, use the following:
`spring.kafka.properties.foo.bar=baz`
[source,properties,indent=0]
----
spring.kafka.properties.foo.bar=baz
----
This sets the common `foo.bar` kafka property to `baz`.
This sets the common `foo.bar` Kafka property to `baz`.
These properties will be shared by both the consumer and producer factory beans.
If you wish to customize these components with different properties, such as to use a
@@ -4659,6 +4662,8 @@ different metrics reader for each, you can override the bean definitions, as fol
include::{code-examples}/kafka/KafkaSpecialProducerConsumerConfigExample.java[tag=configuration]
----
[[boot-features-restclient]]
== Calling REST services
If you need to call remote REST services from your application, you can use Spring

View File

@@ -32,12 +32,11 @@ import org.springframework.kafka.core.DefaultKafkaProducerFactory;
import org.springframework.kafka.core.ProducerFactory;
/**
* Example custom kafka configuration beans used when the user wants to
* apply different common properties to the producer and consumer.
* Example custom kafka configuration beans used when the user wants to apply different
* common properties to the producer and consumer.
*
* @author Gary Russell
* @since 1.5
*
*/
public class KafkaSpecialProducerConsumerConfigExample {
@@ -65,7 +64,8 @@ public class KafkaSpecialProducerConsumerConfigExample {
*/
@Bean
public ConsumerFactory<?, ?> kafkaConsumerFactory(KafkaProperties properties) {
Map<String, Object> consumererProperties = properties.buildConsumerProperties();
Map<String, Object> consumererProperties = properties
.buildConsumerProperties();
consumererProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG,
MyConsumerMetricsReporter.class);
return new DefaultKafkaConsumerFactory<Object, Object>(consumererProperties);