Fix compatibility with Apache Kafka 0.10.1
Update KafkaProperties since Apache Kafka `0.10.1` changed the type
for the `ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG` from the
`Long` to `Integer`.
Kafka includes the following conversion logic:
case LONG:
if (value instanceof Integer)
return ((Integer) value).longValue();
if (value instanceof Long)
return (Long) value;
else if (value instanceof String)
return Long.parseLong(trimmed);
So we remain compatible with both `0.10.0` and `0.10.1`
Closes gh-7723
This commit is contained in:
parent
f21e7940ba
commit
28474aa30a
|
|
@ -43,6 +43,7 @@ import org.springframework.util.CollectionUtils;
|
|||
*
|
||||
* @author Gary Russell
|
||||
* @author Stephane Nicoll
|
||||
* @author Artem Bilan
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.kafka")
|
||||
|
|
@ -199,7 +200,7 @@ public class KafkaProperties {
|
|||
* Frequency in milliseconds that the consumer offsets are auto-committed to Kafka
|
||||
* 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
|
||||
|
|
@ -264,11 +265,11 @@ public class KafkaProperties {
|
|||
return this.ssl;
|
||||
}
|
||||
|
||||
public Long getAutoCommitInterval() {
|
||||
public Integer getAutoCommitInterval() {
|
||||
return this.autoCommitInterval;
|
||||
}
|
||||
|
||||
public void setAutoCommitInterval(Long autoCommitInterval) {
|
||||
public void setAutoCommitInterval(Integer autoCommitInterval) {
|
||||
this.autoCommitInterval = autoCommitInterval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ public class KafkaAutoConfigurationTests {
|
|||
assertThat(configs.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG))
|
||||
.isEqualTo(Boolean.FALSE);
|
||||
assertThat(configs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG))
|
||||
.isEqualTo(123L);
|
||||
.isEqualTo(123);
|
||||
assertThat(configs.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG))
|
||||
.isEqualTo("earliest");
|
||||
assertThat(configs.get(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG)).isEqualTo(456);
|
||||
|
|
|
|||
Loading…
Reference in New Issue