Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6fcbf80b
Commit
6fcbf80b
authored
Jan 04, 2018
by
Gary Russell
Committed by
Stephane Nicoll
Jan 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for additional Kafka listener properties
See gh-11502
parent
2a7b2f30
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
4 deletions
+94
-4
ConcurrentKafkaListenerContainerFactoryConfigurer.java
...ka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
+6
-1
KafkaProperties.java
...ngframework/boot/autoconfigure/kafka/KafkaProperties.java
+66
-1
KafkaAutoConfigurationTests.java
...boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
+16
-1
pom.xml
spring-boot-project/spring-boot-dependencies/pom.xml
+1
-1
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+5
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
View file @
6fcbf80b
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -101,6 +101,11 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer {
.
to
(
container:
:
setAckTime
);
map
.
from
(
properties:
:
getPollTimeout
).
whenNonNull
().
as
(
Duration:
:
toMillis
)
.
to
(
container:
:
setPollTimeout
);
map
.
from
(
properties:
:
getClientId
).
whenNonNull
().
to
(
container:
:
setClientId
);
map
.
from
(
properties:
:
getIdleEventInterval
).
whenNonNull
().
to
(
container:
:
setIdleEventInterval
);
map
.
from
(
properties:
:
getMonitorInterval
).
whenNonNull
().
to
(
container:
:
setMonitorInterval
);
map
.
from
(
properties:
:
getNoPollThreshold
).
whenNonNull
().
to
(
container:
:
setNoPollThreshold
);
map
.
from
(
properties:
:
getLogContainerConfig
).
whenNonNull
().
to
(
container:
:
setLogContainerConfig
);
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
View file @
6fcbf80b
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -818,6 +818,31 @@ public class KafkaProperties {
*/
private
Duration
ackTime
;
/**
* Prefix for the listener's consumer client.id property.
*/
private
String
clientId
;
/**
* Interval (ms) between publishing idle consumer events (no data received).
*/
private
Long
idleEventInterval
;
/**
* Interval (seconds) between checks for non-responsive consumers.
*/
private
Integer
monitorInterval
;
/**
* Multiplier applied to pollTimeout to determine if a consumer is non-responsive.
*/
private
Float
noPollThreshold
;
/**
* When true, log the container configuration during initialization (INFO level).
*/
private
Boolean
logContainerConfig
;
public
Type
getType
()
{
return
this
.
type
;
}
...
...
@@ -866,6 +891,46 @@ public class KafkaProperties {
this
.
ackTime
=
ackTime
;
}
public
String
getClientId
()
{
return
this
.
clientId
;
}
public
void
setClientId
(
String
clientId
)
{
this
.
clientId
=
clientId
;
}
public
Long
getIdleEventInterval
()
{
return
this
.
idleEventInterval
;
}
public
void
setIdleEventInterval
(
Long
idleEventInterval
)
{
this
.
idleEventInterval
=
idleEventInterval
;
}
public
Integer
getMonitorInterval
()
{
return
this
.
monitorInterval
;
}
public
void
setMonitorInterval
(
Integer
monitorInterval
)
{
this
.
monitorInterval
=
monitorInterval
;
}
public
Float
getNoPollThreshold
()
{
return
this
.
noPollThreshold
;
}
public
void
setNoPollThreshold
(
Float
noPollThreshold
)
{
this
.
noPollThreshold
=
noPollThreshold
;
}
public
Boolean
getLogContainerConfig
()
{
return
this
.
logContainerConfig
;
}
public
void
setLogContainerConfig
(
Boolean
logContainerConfig
)
{
this
.
logContainerConfig
=
logContainerConfig
;
}
}
public
static
class
Ssl
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
View file @
6fcbf80b
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -259,6 +259,11 @@ public class KafkaAutoConfigurationTests {
"spring.kafka.listener.concurrency=3"
,
"spring.kafka.listener.poll-timeout=2000"
,
"spring.kafka.listener.type=batch"
,
"spring.kafka.listener.client-id=client"
,
"spring.kafka.listener.idle-event-interval=12345"
,
"spring.kafka.listener.monitor-interval=45"
,
"spring.kafka.listener.no-poll-threshold=2.5"
,
"spring.kafka.listener.log-container-config=true"
,
"spring.kafka.jaas.enabled=true"
,
"spring.kafka.producer.transaction-id-prefix=foo"
,
"spring.kafka.jaas.login-module=foo"
,
...
...
@@ -292,6 +297,16 @@ public class KafkaAutoConfigurationTests {
assertThat
(
dfa
.
getPropertyValue
(
"concurrency"
)).
isEqualTo
(
3
);
assertThat
(
dfa
.
getPropertyValue
(
"containerProperties.pollTimeout"
))
.
isEqualTo
(
2000L
);
assertThat
(
dfa
.
getPropertyValue
(
"containerProperties.clientId"
))
.
isEqualTo
(
"client"
);
assertThat
(
dfa
.
getPropertyValue
(
"containerProperties.idleEventInterval"
))
.
isEqualTo
(
12345L
);
assertThat
(
dfa
.
getPropertyValue
(
"containerProperties.monitorInterval"
))
.
isEqualTo
(
45
);
assertThat
(
dfa
.
getPropertyValue
(
"containerProperties.noPollThreshold"
))
.
isEqualTo
(
2.5f
);
assertThat
(
dfa
.
getPropertyValue
(
"containerProperties.logContainerConfig"
))
.
isEqualTo
(
Boolean
.
TRUE
);
assertThat
(
dfa
.
getPropertyValue
(
"batchListener"
)).
isEqualTo
(
true
);
assertThat
(
context
.
getBeansOfType
(
KafkaJaasLoginModuleInitializer
.
class
))
...
...
spring-boot-project/spring-boot-dependencies/pom.xml
View file @
6fcbf80b
...
...
@@ -149,7 +149,7 @@
<spring-data-releasetrain.version>
Kay-SR2
</spring-data-releasetrain.version>
<spring-hateoas.version>
0.24.0.RELEASE
</spring-hateoas.version>
<spring-integration.version>
5.0.1.BUILD-SNAPSHOT
</spring-integration.version>
<spring-kafka.version>
2.1.
0.RELEASE
</spring-kafka.version>
<spring-kafka.version>
2.1.
1.BUILD-SNAPSHOT
</spring-kafka.version>
<spring-ldap.version>
2.3.2.RELEASE
</spring-ldap.version>
<spring-plugin.version>
1.2.0.RELEASE
</spring-plugin.version>
<spring-restdocs.version>
2.0.0.RELEASE
</spring-restdocs.version>
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
6fcbf80b
...
...
@@ -987,7 +987,12 @@ content into your application. Rather, pick only the properties that you need.
spring.kafka.listener.ack-count= # Number of records between offset commits when ackMode is "COUNT" or "COUNT_TIME".
spring.kafka.listener.ack-mode= # Listener AckMode. See the spring-kafka documentation.
spring.kafka.listener.ack-time= # Time between offset commits when ackMode is "TIME" or "COUNT_TIME".
spring.kafka.listener.client-id= # Prefix for the listener's consumer client.id property.
spring.kafka.listener.concurrency= # Number of threads to run in the listener containers.
spring.kafka.listener.idle-event-interval= # Interval (ms) between publishing idle consumer events (no data received).
spring.kafka.listener.log-container-config= # When true, log the container configuration during initialization (INFO level).
spring.kafka.listener.monitor-interval= # Interval (seconds) between checks for non-responsive consumers.
spring.kafka.listener.no-poll-threshold= # Multiplier applied to pollTimeout to determine if a consumer is non-responsive.
spring.kafka.listener.poll-timeout= # Timeout to use when polling the consumer.
spring.kafka.listener.type=single # Listener type.
spring.kafka.producer.acks= # Number of acknowledgments the producer requires the leader to have received before considering a request complete.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment