Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am starting to work with Spring Boot 2 and Spring Kafka, I don't quite understand what's the difference between
group id
,
Client id
, and
id in
in
KafkaListener
interface.
I know group ID is used by Kafka broker to manage multiple Consumer in the same group, but what about the others? what advantage do I get by setting them? where can I see the effect of setting or not setting them?
Based on their java doc :
* The unique identifier of the container managing for this endpoint.
* <p>If none is specified an auto-generated one is provided.
* @return the {@code id} for the container managing for this endpoint.
* @see org.springframework.kafka.config.KafkaListenerEndpointRegistry#getListenerContainer(String)
String id() default "";
* Override the {@code group.id} property for the consumer factory with this value
* for this listener only.
* @return the group id.
* @since 1.3
String groupId() default "";
* When provided, overrides the client id property in the consumer factory
* configuration. A suffix ('-n') is added for each container instance to ensure
* uniqueness when concurrency is used.
* @return the client id prefix.
* @since 2.1.1
String clientIdPrefix() default "";
Your
groupId
understanding is correct.
The
id
is like a bean name in Spring Framework. However this one is used in the
KafkaListenerEndpointRegistry
boundaries only. So, if you need a lifecycle control over the particular
KafkaListenerContainer
created for the mentioned
@KafkaListener
, you need to inject
KafkaListenerEndpointRegistry
and use the mentioned
getListenerContainer()
for the appropriate
id
.
The
clientIdPrefix
is reflection of exact
client.id
property of the
Kafka Consumer
:
An id string to pass to the server when making requests. The purpose of this is to be able to track the source of requests beyond just ip/port by allowing a logical application name to be included in server-side request logging.
–
–
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.