Skip to content

Commit b710dc7

Browse files
committed
Polish "Use BatchErrorHandler when Kafka listener type is batch"
Closes gh-16499
1 parent 7d2a999 commit b710dc7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void setErrorHandler(ErrorHandler errorHandler) {
9898
* Set the {@link BatchErrorHandler} to use.
9999
* @param batchErrorHandler the error handler
100100
*/
101-
public void setBatchErrorHandler(BatchErrorHandler batchErrorHandler) {
101+
void setBatchErrorHandler(BatchErrorHandler batchErrorHandler) {
102102
this.batchErrorHandler = batchErrorHandler;
103103
}
104104

@@ -133,15 +133,14 @@ private void configureListenerFactory(
133133
map.from(properties::getConcurrency).to(factory::setConcurrency);
134134
map.from(this.messageConverter).to(factory::setMessageConverter);
135135
map.from(this.replyTemplate).to(factory::setReplyTemplate);
136-
map.from(properties::getType).whenEqualTo(Listener.Type.BATCH)
137-
.toCall(() -> factory.setBatchListener(true));
138-
map.from(this.afterRollbackProcessor).to(factory::setAfterRollbackProcessor);
139136
if (properties.getType().equals(Listener.Type.BATCH)) {
137+
factory.setBatchListener(true);
140138
factory.setBatchErrorHandler(this.batchErrorHandler);
141139
}
142140
else {
143141
factory.setErrorHandler(this.errorHandler);
144142
}
143+
map.from(this.afterRollbackProcessor).to(factory::setAfterRollbackProcessor);
145144
}
146145

147146
private void configureContainer(ContainerProperties container) {

0 commit comments

Comments
 (0)