Skip to content

Commit 065c901

Browse files
garyrussellartembilan
authored andcommitted

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2017 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -113,22 +113,29 @@
113113
* The topics for this listener.
114114
* The entries can be 'topic name', 'property-placeholder keys' or 'expressions'.
115115
* An expression must be resolved to the topic name.
116+
* <p>
116117
* Mutually exclusive with {@link #topicPattern()} and {@link #topicPartitions()}.
117118
* @return the topic names or expressions (SpEL) to listen to.
118119
*/
119120
String[] topics() default {};
120121

121122
/**
122-
* The topic pattern for this listener.
123-
* The entries can be 'topic name', 'property-placeholder keys' or 'expressions'.
124-
* An expression must be resolved to the topic pattern.
123+
* The topic pattern for this listener. The entries can be 'topic pattern', a
124+
* 'property-placeholder key' or an 'expression'. The framework will create a
125+
* container that subscribes to all topics matching the specified pattern to get
126+
* dynamically assigned partitions. The pattern matching will be performed
127+
* periodically against topics existing at the time of check. An expression must
128+
* be resolved to the topic pattern (String or Pattern result types are supported).
129+
* <p>
125130
* Mutually exclusive with {@link #topics()} and {@link #topicPartitions()}.
126131
* @return the topic pattern or expression (SpEL).
132+
* @see org.apache.kafka.clients.CommonClientConfigs#METADATA_MAX_AGE_CONFIG
127133
*/
128134
String topicPattern() default "";
129135

130136
/**
131137
* The topicPartitions for this listener.
138+
* <p>
132139
* Mutually exclusive with {@link #topicPattern()} and {@link #topics()}.
133140
* @return the topic names or expressions (SpEL) to listen to.
134141
*/

spring-kafka/src/main/java/org/springframework/kafka/listener/ContainerProperties.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2018 the original author or authors.
2+
* Copyright 2016-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -220,19 +220,37 @@ public enum AckMode {
220220

221221
private boolean missingTopicsFatal = true;
222222

223+
/**
224+
* Create properties for a container that will subscribe to the specified topics.
225+
* @param topics the topics.
226+
*/
223227
public ContainerProperties(String... topics) {
224228
Assert.notEmpty(topics, "An array of topics must be provided");
225229
this.topics = Arrays.asList(topics).toArray(new String[topics.length]);
226230
this.topicPattern = null;
227231
this.topicPartitions = null;
228232
}
229233

234+
/**
235+
* Create properties for a container that will subscribe to topics matching the
236+
* specified pattern. The framework will create a container that subscribes to all
237+
* topics matching the specified pattern to get dynamically assigned partitions. The
238+
* pattern matching will be performed periodically against topics existing at the time
239+
* of check.
240+
* @param topicPattern the pattern.
241+
* @see org.apache.kafka.clients.CommonClientConfigs#METADATA_MAX_AGE_CONFIG
242+
*/
230243
public ContainerProperties(Pattern topicPattern) {
231244
this.topics = null;
232245
this.topicPattern = topicPattern;
233246
this.topicPartitions = null;
234247
}
235248

249+
/**
250+
* Create properties for a container that will assign itself the provided topic
251+
* partitions.
252+
* @param topicPartitions the topic partitions.
253+
*/
236254
public ContainerProperties(TopicPartitionInitialOffset... topicPartitions) {
237255
this.topics = null;
238256
this.topicPattern = null;

0 commit comments

Comments
 (0)