Skip to content

Commit b1e6756

Browse files
Some cosmetic improvements of the reference - part 2
* tweak as per PR comments
1 parent 9794c58 commit b1e6756

File tree

14 files changed

+67
-69
lines changed

14 files changed

+67
-69
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/container-props.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ The time to process a batch of records plus this value must be less than the `ma
112112

113113
|[[idleEventInterval]]<<idleEventInterval,`idleEventInterval`>>
114114
|`null`
115-
|When set, enables publication of `ListenerContainerIdleEvent` s, see xref:kafka/events.adoc[Application Events] and xref:kafka/events.adoc#idle-containers[Detecting Idle and Non-Responsive Consumers].
115+
|When set, enables publication of `ListenerContainerIdleEvent`+++s+++, see xref:kafka/events.adoc[Application Events] and xref:kafka/events.adoc#idle-containers[Detecting Idle and Non-Responsive Consumers].
116116
Also see `idleBeforeDataMultiplier`.
117117

118118
|[[idlePartitionEventInterval]]<<idlePartitionEventInterval,`idlePartitionEventInterval`>>
119119
|`null`
120-
|When set, enables publication of `ListenerContainerIdlePartitionEvent` s, see xref:kafka/events.adoc[Application Events] and xref:kafka/events.adoc#idle-containers[Detecting Idle and Non-Responsive Consumers].
120+
|When set, enables publication of `ListenerContainerIdlePartitionEvent`+++s+++, see xref:kafka/events.adoc[Application Events] and xref:kafka/events.adoc#idle-containers[Detecting Idle and Non-Responsive Consumers].
121121

122122
|[[kafkaConsumerProperties]]<<kafkaConsumerProperties,`kafkaConsumerProperties`>>
123123
|None
@@ -274,7 +274,7 @@ See xref:kafka/annotation-error-handling.adoc#error-handlers[Container Error Han
274274

275275
|[[listenerId]]<<listenerId,`listenerId`>>
276276
|See desc.
277-
|The bean name for user-configured containers or the `id` attribute of `@KafkaListener` s.
277+
|The bean name for user-configured containers or the `id` attribute of `@KafkaListener`+++s+++.
278278

279279
|[[listenerInfo]]<<listenerInfo,`listenerInfo`>>
280280
|null
@@ -333,22 +333,22 @@ Also see `interceptBeforeTx`.
333333

334334
|[[assignedPartitions2]]<<assignedPartitions2,`assignedPartitions`>>
335335
|(read only)
336-
|The aggregate of partitions currently assigned to this container's child `KafkaMessageListenerContainer` s (explicitly or not).
336+
|The aggregate of partitions currently assigned to this container's child `KafkaMessageListenerContainer`+++s+++ (explicitly or not).
337337

338338
|[[assignedPartitionsByClientId2]]<<assignedPartitionsByClientId2,`assignedPartitionsByClientId`>>
339339
|(read only)
340-
|The partitions currently assigned to this container's child `KafkaMessageListenerContainer` s (explicitly or not), keyed by the child container's consumer's `client.id` property.
340+
|The partitions currently assigned to this container's child `KafkaMessageListenerContainer`+++s+++ (explicitly or not), keyed by the child container's consumer's `client.id` property.
341341

342342
|[[concurrency]]<<concurrency,`concurrency`>>
343343
|1
344-
|The number of child `KafkaMessageListenerContainer` s to manage.
344+
|The number of child `KafkaMessageListenerContainer`+++s+++ to manage.
345345

346346
|[[containerPaused2]]<<containerPaused2,`containerPaused`>>
347347
|n/a
348348
|True if pause has been requested and all child containers' consumer has actually paused.
349349

350350
|[[containers]]<<containers,`containers`>>
351351
|n/a
352-
|A reference to all child `KafkaMessageListenerContainer` s.
352+
|A reference to all child `KafkaMessageListenerContainer`+++s+++.
353353
|===
354354

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/events.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
The following Spring application events are published by listener containers and their consumers:
55

6-
* `ConsumerStartingEvent` - published when a consumer thread is first started, before it starts polling.
7-
* `ConsumerStartedEvent` - published when a consumer is about to start polling.
8-
* `ConsumerFailedToStartEvent` - published if no `ConsumerStartingEvent` is published within the `consumerStartTimeout` container property.
6+
* `ConsumerStartingEvent`: published when a consumer thread is first started, before it starts polling.
7+
* `ConsumerStartedEvent`: published when a consumer is about to start polling.
8+
* `ConsumerFailedToStartEvent`: published if no `ConsumerStartingEvent` is published within the `consumerStartTimeout` container property.
99
This event might signal that the configured task executor has insufficient threads to support the containers it is used in and their concurrency.
1010
An error message is also logged when this condition occurs.
1111
* `ListenerContainerIdleEvent`: published when no messages have been received in `idleInterval` (if configured).
@@ -85,7 +85,7 @@ The `ConsumerRetryAuthEvent` event has the following properties:
8585

8686
* `source`: The listener container instance that published the event.
8787
* `container`: The listener container or the parent listener container, if the source container is a child.
88-
* `reason`
88+
* `reason`:
8989
** `AUTHENTICATION` - the event was published because of an authentication exception.
9090
** `AUTHORIZATION` - the event was published because of an authorization exception.
9191

@@ -99,7 +99,7 @@ For a parent container, the source and container properties are identical.
9999

100100
In addition, the `ConsumerStoppedEvent` has the following additional property:
101101

102-
* `reason`
102+
* `reason`:
103103
** `NORMAL` - the consumer stopped normally (container was stopped).
104104
** `ERROR` - a `java.lang.Error` was thrown.
105105
** `FENCED` - the transactional producer was fenced and the `stopContainerWhenFenced` container property is `true`.
@@ -135,7 +135,7 @@ public KafkaMessageListenerContainer(ConsumerFactory<String, String> consumerFac
135135
...
136136
containerProps.setIdleEventInterval(60000L);
137137
...
138-
KafkaMessageListenerContainer<String, String> container = new KafKaMessageListenerContainer<>(...);
138+
KafkaMessageListenerContainer<String, String> container = new KafKaMessageListenerContainer<>(consumerFactory, containerProps);
139139
return container;
140140
}
141141
----
@@ -174,7 +174,7 @@ You can also use `@EventListener`, introduced in Spring Framework 4.2.
174174

175175
The next example combines `@KafkaListener` and `@EventListener` into a single class.
176176
You should understand that the application listener gets events for all containers, so you may need to check the listener ID if you want to take specific action based on which container is idle.
177-
You can also use the `@EventListener` `condition` for this purpose.
177+
You can also use the `@EventListener`+++'+++s `condition` for this purpose.
178178

179179
See xref:kafka/events.adoc[Application Events] for information about event properties.
180180

@@ -214,5 +214,5 @@ You should stop the concurrent container instead.
214214
=== Current Positions when Idle
215215

216216
Note that you can obtain the current positions when idle is detected by implementing `ConsumerSeekAware` in your listener.
217-
See `onIdleContainer()` in <<seek>>.
217+
See `onIdleContainer()` in xref:kafka/seek.adoc[seek].
218218

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/annotation-send-to.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Starting with version 2.0, if you also annotate a `@KafkaListener` with a `@Send
55

66
The `@SendTo` value can have several forms:
77

8-
* `@SendTo("someTopic")` routes to the literal topic
8+
* `@SendTo("someTopic")` routes to the literal topic.
99
* `+@SendTo("#{someExpression}")+` routes to the topic determined by evaluating the expression once during application context initialization.
1010
* `+@SendTo("!{someExpression}")+` routes to the topic determined by evaluating the expression at runtime.
1111
The `#root` object for the evaluation has three properties:
12-
** `request`: The inbound `ConsumerRecord` (or `ConsumerRecords` object for a batch listener))
12+
** `request`: The inbound `ConsumerRecord` (or `ConsumerRecords` object for a batch listener).
1313
** `source`: The `org.springframework.messaging.Message<?>` converted from the `request`.
1414
** `result`: The method return result.
1515
* `@SendTo` (no properties): This is treated as `!{source.headers['kafka_replyTopic']}` (since version 2.1.3).
@@ -60,7 +60,7 @@ public class MultiListenerSendTo {
6060

6161
IMPORTANT: In order to support `@SendTo`, the listener container factory must be provided with a `KafkaTemplate` (in its `replyTemplate` property), which is used to send the reply.
6262
This should be a `KafkaTemplate` and not a `ReplyingKafkaTemplate` which is used on the client-side for request/reply processing.
63-
When using Spring Boot, boot will auto-configure the template into the factory; when configuring your own factory, it must be set as shown in the examples below.
63+
When using Spring Boot, it will auto-configure the template into the factory; when configuring your own factory, it must be set as shown in the examples below.
6464

6565
Starting with version 2.2, you can add a `ReplyHeadersConfigurer` to the listener container factory.
6666
This is consulted to determine which headers you want to set in the reply message.
@@ -108,9 +108,9 @@ public ConcurrentKafkaListenerContainerFactory<Integer, String> kafkaListenerCon
108108
----
109109

110110
When you use `@SendTo`, you must configure the `ConcurrentKafkaListenerContainerFactory` with a `KafkaTemplate` in its `replyTemplate` property to perform the send.
111-
Spring Boot will automatically wire in its auto configured template (or any if a single instance is present).
111+
Spring Boot will automatically wire in its auto-configured template (or any if a single instance is present).
112112

113-
NOTE: Unless you use xref:kafka/sending-messages.adoc#replying-template[request/reply semantics] only the simple `send(topic, value)` method is used, so you may wish to create a subclass to generate the partition or key.
113+
NOTE: Unless you use xref:kafka/sending-messages.adoc#replying-template[request/reply semantics], only the simple `send(topic, value)` method is used, so you may wish to create a subclass to generate the partition or key.
114114
The following example shows how to do so:
115115

116116
[source, java]

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/filtering.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
In certain scenarios, such as rebalancing, a message that has already been processed may be redelivered.
55
The framework cannot know whether such a message has been processed or not.
66
That is an application-level function.
7-
This is known as the https://www.enterpriseintegrationpatterns.com/patterns/messaging/IdempotentReceiver.html[Idempotent Receiver] pattern and Spring Integration provides an https://docs.spring.io/spring-integration/reference/html/#idempotent-receiver[implementation of it].
7+
This is known as the https://www.enterpriseintegrationpatterns.com/patterns/messaging/IdempotentReceiver.html[Idempotent Receiver] pattern and Spring Integration provides an https://docs.spring.io/spring-integration/reference/html/#idempotent-receiver[implementation] of it.
88

99
The Spring for Apache Kafka project also provides some assistance by means of the `FilteringMessageListenerAdapter` class, which can wrap your `MessageListener`.
1010
This class takes an implementation of `RecordFilterStrategy` in which you implement the `filter` method to signal that a message is a duplicate and should be discarded.
@@ -13,7 +13,7 @@ It is `false` by default.
1313

1414
When you use `@KafkaListener`, set the `RecordFilterStrategy` (and optionally `ackDiscarded`) on the container factory so that the listener is wrapped in the appropriate filtering adapter.
1515

16-
In addition, a `FilteringBatchMessageListenerAdapter` is provided, for when you use a batch <<message-listeners, message listener>>.
16+
In addition, a `FilteringBatchMessageListenerAdapter` is provided, for when you use a batch xref:kafka/receiving-messages/message-listeners.adoc[message listener].
1717

1818
IMPORTANT: The `FilteringBatchMessageListenerAdapter` is ignored if your `@KafkaListener` receives a `ConsumerRecords<?, ?>` instead of `List<ConsumerRecord<?, ?>>`, because `ConsumerRecords` is immutable.
1919

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/listener-annotation.adoc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,17 @@ The following example shows how to do so:
270270
[source, java]
271271
----
272272
@KafkaListener(id = "listMsg", topics = "myTopic", containerFactory = "batchFactory")
273-
public void listen14(List<Message<?>> list) {
273+
public void listen1(List<Message<?>> list) {
274274
...
275275
}
276276
277277
@KafkaListener(id = "listMsgAck", topics = "myTopic", containerFactory = "batchFactory")
278-
public void listen15(List<Message<?>> list, Acknowledgment ack) {
278+
public void listen2(List<Message<?>> list, Acknowledgment ack) {
279279
...
280280
}
281281
282282
@KafkaListener(id = "listMsgAckConsumer", topics = "myTopic", containerFactory = "batchFactory")
283-
public void listen16(List<Message<?>> list, Acknowledgment ack, Consumer<?, ?> consumer) {
283+
public void listen3(List<Message<?>> list, Acknowledgment ack, Consumer<?, ?> consumer) {
284284
...
285285
}
286286
----
@@ -386,13 +386,12 @@ The following example shows how to do so:
386386

387387
[source, java]
388388
----
389-
@KafkaListener(beanRef = "__x", topics = "#{__x.topic}",
390-
groupId = "#{__x.topic}.group")
389+
@KafkaListener(beanRef = "__x", topics = "#{__x.topic}", groupId = "#{__x.topic}.group")
391390
----
392391

393392
Starting with version 2.2.4, you can specify Kafka consumer properties directly on the annotation, these will override any properties with the same name configured in the consumer factory. You **cannot** specify the `group.id` and `client.id` properties this way; they will be ignored; use the `groupId` and `clientIdPrefix` annotation properties for those.
394393

395-
The properties are specified as individual strings with the normal Java `Properties` file format: `foo:bar`, `foo=bar`, or `foo bar`.
394+
The properties are specified as individual strings with the normal Java `Properties` file format: `foo:bar`, `foo=bar`, or `foo bar`, as the following example shows:
396395

397396
[source, java]
398397
----

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/listener-group-id.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ Alternatively, you can access the group id in a method parameter.
1010
[source, java]
1111
----
1212
@KafkaListener(id = "id", topicPattern = "someTopic")
13-
public void listener(@Payload String payload,
14-
@Header(KafkaHeaders.GROUP_ID) String groupId) {
15-
...
13+
public void listener(@Payload String payload, @Header(KafkaHeaders.GROUP_ID) String groupId) {
14+
...
1615
}
1716
----
1817

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/message-listener-container.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `ConcurrentMessageListenerContainer` delegates to one or more `KafkaMessageL
1212
Starting with version 2.2.7, you can add a `RecordInterceptor` to the listener container; it will be invoked before calling the listener allowing inspection or modification of the record.
1313
If the interceptor returns null, the listener is not called.
1414
Starting with version 2.7, it has additional methods which are called after the listener exits (normally, or by throwing an exception).
15-
Also, starting with version 2.7, there is now a `BatchInterceptor`, providing similar functionality for <<batch-listeners>>.
15+
Also, starting with version 2.7, there is now a `BatchInterceptor`, providing similar functionality for xref:kafka/receiving-messages/listener-annotation.adoc#batch-listeners[Batch Listeners].
1616
In addition, the `ConsumerAwareRecordInterceptor` (and `BatchInterceptor`) provide access to the `Consumer<?, ?>`.
1717
This might be used, for example, to access the consumer metrics in the interceptor.
1818

@@ -24,7 +24,7 @@ The `CompositeRecordInterceptor` and `CompositeBatchInterceptor` can be used to
2424

2525
By default, starting with version 2.8, when using transactions, the interceptor is invoked before the transaction has started.
2626
You can set the listener container's `interceptBeforeTx` property to `false` to invoke the interceptor after the transaction has started instead.
27-
Starting with version 2.9, this will apply to any transaction manager, not just `KafkaAwareTransactionManager` s.
27+
Starting with version 2.9, this will apply to any transaction manager, not just `KafkaAwareTransactionManager`+++s+++.
2828
This allows, for example, the interceptor to participate in a JDBC transaction started by the container.
2929

3030
Starting with versions 2.3.8, 2.4.6, the `ConcurrentMessageListenerContainer` now supports https://kafka.apache.org/documentation/#static_membership[Static Membership] when the concurrency is greater than one.
@@ -155,7 +155,7 @@ org.apache.kafka.clients.consumer.RoundRobinAssignor
155155
=====
156156
====
157157

158-
When the container properties are configured with `TopicPartitionOffset` s, the `ConcurrentMessageListenerContainer` distributes the `TopicPartitionOffset` instances across the delegate `KafkaMessageListenerContainer` instances.
158+
When the container properties are configured with `TopicPartitionOffset`+++s+++, the `ConcurrentMessageListenerContainer` distributes the `TopicPartitionOffset` instances across the delegate `KafkaMessageListenerContainer` instances.
159159

160160
If, say, six `TopicPartitionOffset` instances are provided and the `concurrency` is `3`; each container gets two partitions.
161161
For five `TopicPartitionOffset` instances, two containers get two partitions, and the third gets one.
@@ -196,14 +196,14 @@ After that, the same semantics as `BATCH` are applied.
196196

197197
When using xref:kafka/transactions.adoc[transactions], the offset(s) are sent to the transaction and the semantics are equivalent to `RECORD` or `BATCH`, depending on the listener type (record or batch).
198198

199-
NOTE: `MANUAL`, and `MANUAL_IMMEDIATE` require the listener to be an `AcknowledgingMessageListener` or a `BatchAcknowledgingMessageListener`.
200-
See <<message-listeners, Message Listeners>>.
199+
NOTE: `MANUAL` and `MANUAL_IMMEDIATE` require the listener to be an `AcknowledgingMessageListener` or a `BatchAcknowledgingMessageListener`.
200+
See xref:kafka/receiving-messages/message-listeners.adoc[Message Listeners].
201201

202202
Depending on the `syncCommits` container property, the `commitSync()` or `commitAsync()` method on the consumer is used.
203203
`syncCommits` is `true` by default; also see `setSyncCommitTimeout`.
204204
See `setCommitCallback` to get the results of asynchronous commits; the default callback is the `LoggingCommitCallback` which logs errors (and successes at debug level).
205205

206-
Because the listener container has it's own mechanism for committing offsets, it prefers the Kafka `ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG` to be `false`.
206+
Because the listener container has its own mechanism for committing offsets, it prefers the Kafka `ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG` to be `false`.
207207
Starting with version 2.3, it unconditionally sets it to false unless specifically set in the consumer factory or the container's consumer property overrides.
208208

209209
The `Acknowledgment` has the following method:

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/message-listeners.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ Access to the `Consumer` object is provided.
8181
IMPORTANT: The `Consumer` object is not thread-safe.
8282
You must only invoke its methods on the thread that calls the listener.
8383

84-
IMPORTANT: You should not execute any `Consumer<?, ?>` methods that affect the consumer's positions and or committed offsets in your listener; the container needs to manage such information.
84+
IMPORTANT: You should not execute any `Consumer<?, ?>` methods that affect the consumer's positions or committed offsets in your listener; the container needs to manage such information.
8585

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/rebalance-listeners.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ containerProperties.setConsumerRebalanceListener(new ConsumerAwareRebalanceListe
3838
@Override
3939
public void onPartitionsRevokedAfterCommit(Consumer<?, ?> consumer, Collection<TopicPartition> partitions) {
4040
// ...
41-
store(consumer.position(partition));
41+
store(consumer.position(partition));
4242
// ...
4343
}
4444
4545
@Override
4646
public void onPartitionsAssigned(Collection<TopicPartition> partitions) {
4747
// ...
48-
consumer.seek(partition, offsetTracker.getOffset() + 1);
48+
consumer.seek(partition, offsetTracker.getOffset() + 1);
4949
// ...
5050
}
5151
});
@@ -54,7 +54,7 @@ containerProperties.setConsumerRebalanceListener(new ConsumerAwareRebalanceListe
5454
IMPORTANT: Starting with version 2.4, a new method `onPartitionsLost()` has been added (similar to a method with the same name in `ConsumerRebalanceLister`).
5555
The default implementation on `ConsumerRebalanceLister` simply calls `onPartionsRevoked`.
5656
The default implementation on `ConsumerAwareRebalanceListener` does nothing.
57-
When supplying the listener container with a custom listener (of either type), it is important that your implementation not call `onPartitionsRevoked` from `onPartitionsLost`.
57+
When supplying the listener container with a custom listener (of either type), it is important that your implementation does not call `onPartitionsRevoked` from `onPartitionsLost`.
5858
If you implement `ConsumerRebalanceListener` you should override the default method.
5959
This is because the listener container will call its own `onPartitionsRevoked` from its implementation of `onPartitionsLost` after calling the method on your implementation.
6060
If you implementation delegates to the default behavior, `onPartitionsRevoked` will be called twice each time the `Consumer` calls that method on the container's listener.

0 commit comments

Comments
 (0)