11/*
2- * Copyright 2018-2021 the original author or authors.
2+ * Copyright 2018-2022 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.
2929import org .springframework .core .task .TaskExecutor ;
3030import org .springframework .kafka .annotation .KafkaListener ;
3131import org .springframework .kafka .core .KafkaOperations ;
32+ import org .springframework .kafka .listener .CommonErrorHandler ;
3233import org .springframework .kafka .listener .DeadLetterPublishingRecoverer ;
33- import org .springframework .kafka .listener .SeekToCurrentErrorHandler ;
34+ import org .springframework .kafka .listener .DefaultErrorHandler ;
3435import org .springframework .kafka .support .converter .JsonMessageConverter ;
3536import org .springframework .kafka .support .converter .RecordMessageConverter ;
3637import org .springframework .util .backoff .FixedBackOff ;
@@ -59,8 +60,8 @@ public static void main(String[] args) {
5960 * Boot will autowire this into the container factory.
6061 */
6162 @ Bean
62- public SeekToCurrentErrorHandler errorHandler (KafkaOperations <Object , Object > template ) {
63- return new SeekToCurrentErrorHandler (
63+ public CommonErrorHandler errorHandler (KafkaOperations <Object , Object > template ) {
64+ return new DefaultErrorHandler (
6465 new DeadLetterPublishingRecoverer (template ), new FixedBackOff (1000L , 2 ));
6566 }
6667
@@ -79,8 +80,8 @@ public void listen(Foo2 foo) {
7980 }
8081
8182 @ KafkaListener (id = "dltGroup" , topics = "topic1.DLT" )
82- public void dltListen (String in ) {
83- logger .info ("Received from DLT: " + in );
83+ public void dltListen (byte [] in ) {
84+ logger .info ("Received from DLT: " + new String ( in ) );
8485 this .exec .execute (() -> System .out .println ("Hit Enter to terminate..." ));
8586 }
8687
0 commit comments