Merge pull request #7723 from artembilan/KafkaPropertiesTypes

* pr/7723:
  Fix typo in Kafka sample
  Fix compatibility with Apache Kafka 0.10.1
This commit is contained in:
Phillip Webb 2016-12-21 15:01:28 -08:00
commit 2e0f87e753
3 changed files with 8 additions and 8 deletions

View File

@ -43,6 +43,7 @@ import org.springframework.util.CollectionUtils;
* *
* @author Gary Russell * @author Gary Russell
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Artem Bilan
* @since 1.5.0 * @since 1.5.0
*/ */
@ConfigurationProperties(prefix = "spring.kafka") @ConfigurationProperties(prefix = "spring.kafka")
@ -199,7 +200,7 @@ public class KafkaProperties {
* Frequency in milliseconds that the consumer offsets are auto-committed to Kafka * Frequency in milliseconds that the consumer offsets are auto-committed to Kafka
* if 'enable.auto.commit' true. * if 'enable.auto.commit' true.
*/ */
private Long autoCommitInterval; private Integer autoCommitInterval;
/** /**
* What to do when there is no initial offset in Kafka or if the current offset * What to do when there is no initial offset in Kafka or if the current offset
@ -264,11 +265,11 @@ public class KafkaProperties {
return this.ssl; return this.ssl;
} }
public Long getAutoCommitInterval() { public Integer getAutoCommitInterval() {
return this.autoCommitInterval; return this.autoCommitInterval;
} }
public void setAutoCommitInterval(Long autoCommitInterval) { public void setAutoCommitInterval(Integer autoCommitInterval) {
this.autoCommitInterval = autoCommitInterval; this.autoCommitInterval = autoCommitInterval;
} }

View File

@ -100,7 +100,7 @@ public class KafkaAutoConfigurationTests {
assertThat(configs.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG)) assertThat(configs.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG))
.isEqualTo(Boolean.FALSE); .isEqualTo(Boolean.FALSE);
assertThat(configs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG)) assertThat(configs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG))
.isEqualTo(123L); .isEqualTo(123);
assertThat(configs.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG)) assertThat(configs.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG))
.isEqualTo("earliest"); .isEqualTo("earliest");
assertThat(configs.get(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG)).isEqualTo(456); assertThat(configs.get(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG)).isEqualTo(456);

View File

@ -64,11 +64,10 @@ public class KafkaSpecialProducerConsumerConfigExample {
*/ */
@Bean @Bean
public ConsumerFactory<?, ?> kafkaConsumerFactory(KafkaProperties properties) { public ConsumerFactory<?, ?> kafkaConsumerFactory(KafkaProperties properties) {
Map<String, Object> consumererProperties = properties Map<String, Object> consumerProperties = properties.buildConsumerProperties();
.buildConsumerProperties(); consumerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG,
consumererProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG,
MyConsumerMetricsReporter.class); MyConsumerMetricsReporter.class);
return new DefaultKafkaConsumerFactory<Object, Object>(consumererProperties); return new DefaultKafkaConsumerFactory<Object, Object>(consumerProperties);
} }
} }