You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/asciidoc/retrytopic.adoc
+90Lines changed: 90 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -227,6 +227,96 @@ public class Config extends RetryTopicConfigurationSupport {
227
227
The parameters to the function are the consumer record and the name of the next topic.
228
228
You can return a specific partition number, or `null` to indicate that the `KafkaProducer` should determine the partition.
229
229
230
+
==== Programmatic Construction
231
+
232
+
The feature is designed to be used with `@KafkaListener`; however, several users have requested information on how to configure non-blocking retries programmatically.
233
+
The following Spring Boot application provides an example of how to do so.
234
+
235
+
====
236
+
[source, java]
237
+
----
238
+
@SpringBootApplication
239
+
public class Application extends RetryTopicConfigurationSupport {
class Listener implements MessageListener<String, String> {
306
+
307
+
@Override
308
+
public void onMessage(ConsumerRecord<String, String> record) {
309
+
System.out.println(KafkaUtils.format(record));
310
+
throw new RuntimeException("test");
311
+
}
312
+
313
+
}
314
+
----
315
+
====
316
+
317
+
IMPORTANT: Auto creation of topics will only occur if the configuration is processed before the application context is refereshed, as in the above example.
318
+
To configure containers at runtime, the topics will need to be created using some other technique.
319
+
230
320
==== Features
231
321
232
322
Most of the features are available both for the `@RetryableTopic` annotation and the `RetryTopicConfiguration` beans.
Copy file name to clipboardExpand all lines: spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -240,6 +240,15 @@ public MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
240
240
returnthis.messageHandlerMethodFactory;
241
241
}
242
242
243
+
/**
244
+
* Return the {@link KafkaListenerEndpointRegistrar}.
0 commit comments