Skip to content

Commit 9fef537

Browse files
garyrussellartembilan
authored andcommitted
GH-906: @KafkaListener Javadoc Improvements
Resolves #906
1 parent b279945 commit 9fef537

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListener.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
* <p>Note: When provided, this value will override the group id property
9696
* in the consumer factory configuration, unless {@link #idIsGroup()}
9797
* is set to false.
98+
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
9899
* @return the {@code id} for the container managing for this endpoint.
99100
* @see org.springframework.kafka.config.KafkaListenerEndpointRegistry#getListenerContainer(String)
100101
*/
@@ -111,7 +112,7 @@
111112
/**
112113
* The topics for this listener.
113114
* The entries can be 'topic name', 'property-placeholder keys' or 'expressions'.
114-
* Expression must be resolved to the topic name.
115+
* An expression must be resolved to the topic name.
115116
* Mutually exclusive with {@link #topicPattern()} and {@link #topicPartitions()}.
116117
* @return the topic names or expressions (SpEL) to listen to.
117118
*/
@@ -120,7 +121,7 @@
120121
/**
121122
* The topic pattern for this listener.
122123
* The entries can be 'topic name', 'property-placeholder keys' or 'expressions'.
123-
* Expression must be resolved to the topic pattern.
124+
* An expression must be resolved to the topic pattern.
124125
* Mutually exclusive with {@link #topics()} and {@link #topicPartitions()}.
125126
* @return the topic pattern or expression (SpEL).
126127
*/
@@ -138,13 +139,14 @@
138139
* with this value as its name, of type {@code Collection<MessageListenerContainer>}.
139140
* This allows, for example, iteration over the collection to start/stop a subset
140141
* of containers.
142+
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
141143
* @return the bean name for the group.
142144
*/
143145
String containerGroup() default "";
144146

145147
/**
146-
* Set an {@link org.springframework.kafka.listener.KafkaListenerErrorHandler} to
147-
* invoke if the listener method throws an exception.
148+
* Set an {@link org.springframework.kafka.listener.KafkaListenerErrorHandler} bean
149+
* name to invoke if the listener method throws an exception.
148150
* @return the error handler.
149151
* @since 1.3
150152
*/
@@ -153,6 +155,7 @@
153155
/**
154156
* Override the {@code group.id} property for the consumer factory with this value
155157
* for this listener only.
158+
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
156159
* @return the group id.
157160
* @since 1.3
158161
*/
@@ -171,6 +174,7 @@
171174
* When provided, overrides the client id property in the consumer factory
172175
* configuration. A suffix ('-n') is added for each container instance to ensure
173176
* uniqueness when concurrency is used.
177+
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
174178
* @return the client id prefix.
175179
* @since 2.1.1
176180
*/
@@ -192,6 +196,7 @@
192196
* Override the container factory's {@code concurrency} setting for this listener. May
193197
* be a property placeholder or SpEL expression that evaluates to a {@link Number}, in
194198
* which case {@link Number#intValue()} is used to obtain the value.
199+
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
195200
* @return the concurrency.
196201
* @since 2.2
197202
*/
@@ -202,6 +207,7 @@
202207
* be a property placeholder or SpEL expression that evaluates to a {@link Boolean} or
203208
* a {@link String}, in which case the {@link Boolean#parseBoolean(String)} is used to
204209
* obtain the value.
210+
* <p>SpEL {@code #{...}} and property place holders {@code ${...}} are supported.
205211
* @return true to auto start, false to not auto start.
206212
* @since 2.2
207213
*/

src/reference/asciidoc/kafka.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,13 @@ The `- 100` leaves room for later phases to enable components to be auto-started
755755
[[kafka-listener-annotation]]
756756
===== @KafkaListener Annotation
757757

758+
====== Introduction
759+
760+
The `@KafkaListener` annotation is used to designate a bean method as a listener for a listener container; the bean is wrapped in a `MessagingMessageListenerAdapter` configured with various features, such as converters to convert the data, if necessary, to match the method paramters.
761+
762+
Most attributes on the annotation can be configured with SpEL using `#{...}` and/or property placeholders `${...}`.
763+
Refer to the javadocs for more information.
764+
758765
[[record-listener]]
759766
====== Record Listeners
760767

0 commit comments

Comments
 (0)