95
95
RetryTopicIntegrationTests .THIRD_TOPIC ,
96
96
RetryTopicIntegrationTests .FOURTH_TOPIC ,
97
97
RetryTopicIntegrationTests .TWO_LISTENERS_TOPIC })
98
- @ TestPropertySource (properties = "five.attempts=5" )
98
+ @ TestPropertySource (properties = { "five.attempts=5" , "kafka.template=customKafkaTemplate" } )
99
99
public class RetryTopicIntegrationTests extends AbstractRetryTopicIntegrationTests {
100
100
101
101
private static final Logger logger = LoggerFactory .getLogger (RetryTopicIntegrationTests .class );
@@ -286,7 +286,7 @@ static class ThirdTopicListener {
286
286
backoff = @ Backoff (delay = 250 , maxDelay = 1000 , multiplier = 1.5 ),
287
287
numPartitions = "#{3}" ,
288
288
timeout = "${missing.property:2000}" ,
289
- include = MyRetryException .class , kafkaTemplate = "kafkaTemplate " ,
289
+ include = MyRetryException .class , kafkaTemplate = "${kafka.template} " ,
290
290
topicSuffixingStrategy = TopicSuffixingStrategy .SUFFIX_WITH_INDEX_VALUE ,
291
291
concurrency = "1" )
292
292
@ KafkaListener (id = "thirdTopicId" , topics = THIRD_TOPIC , containerFactory = MAIN_TOPIC_CONTAINER_FACTORY ,
@@ -311,7 +311,7 @@ static class FourthTopicListener {
311
311
CountDownLatchContainer container ;
312
312
313
313
@ RetryableTopic (dltStrategy = DltStrategy .NO_DLT , attempts = "4" , backoff = @ Backoff (300 ),
314
- kafkaTemplate = "kafkaTemplate " )
314
+ kafkaTemplate = "${kafka.template} " )
315
315
@ KafkaListener (topics = FOURTH_TOPIC , containerFactory = MAIN_TOPIC_CONTAINER_FACTORY )
316
316
public void listenNoDlt (String message , @ Header (KafkaHeaders .RECEIVED_TOPIC ) String receivedTopic ) {
317
317
logger .debug ("Message {} received in topic {} " , message , receivedTopic );
@@ -337,7 +337,7 @@ static class FifthTopicListener1 {
337
337
numPartitions = "2" ,
338
338
retryTopicSuffix = "-listener1" , dltTopicSuffix = "-listener1-dlt" ,
339
339
topicSuffixingStrategy = TopicSuffixingStrategy .SUFFIX_WITH_INDEX_VALUE ,
340
- kafkaTemplate = "kafkaTemplate " )
340
+ kafkaTemplate = "${kafka.template} " )
341
341
@ KafkaListener (id = "fifthTopicId1" , topicPartitions = {@ TopicPartition (topic = TWO_LISTENERS_TOPIC ,
342
342
partitionOffsets = @ PartitionOffset (partition = "0" , initialOffset = "0" ))},
343
343
containerFactory = MAIN_TOPIC_CONTAINER_FACTORY )
@@ -369,7 +369,7 @@ static class FifthTopicListener2 {
369
369
numPartitions = "2" ,
370
370
retryTopicSuffix = "-listener2" , dltTopicSuffix = "-listener2-dlt" ,
371
371
topicSuffixingStrategy = TopicSuffixingStrategy .SUFFIX_WITH_INDEX_VALUE ,
372
- kafkaTemplate = "kafkaTemplate " )
372
+ kafkaTemplate = "${kafka.template} " )
373
373
@ KafkaListener (id = "fifthTopicId2" , topicPartitions = {@ TopicPartition (topic = TWO_LISTENERS_TOPIC ,
374
374
partitionOffsets = @ PartitionOffset (partition = "1" , initialOffset = "0" ))},
375
375
containerFactory = MAIN_TOPIC_CONTAINER_FACTORY )
@@ -397,7 +397,7 @@ static class NoRetryTopicListener {
397
397
398
398
@ RetryableTopic (attempts = "3" , numPartitions = "3" , exclude = MyDontRetryException .class ,
399
399
backoff = @ Backoff (delay = 50 , maxDelay = 100 , multiplier = 3 ),
400
- traversingCauses = "true" , kafkaTemplate = "kafkaTemplate " )
400
+ traversingCauses = "true" , kafkaTemplate = "${kafka.template} " )
401
401
@ KafkaListener (topics = NOT_RETRYABLE_EXCEPTION_TOPIC , containerFactory = MAIN_TOPIC_CONTAINER_FACTORY )
402
402
public void listenWithAnnotation2 (String message , @ Header (KafkaHeaders .RECEIVED_TOPIC ) String receivedTopic ) {
403
403
container .countDownIfNotKnown (receivedTopic , container .countDownLatchNoRetry );
@@ -592,7 +592,7 @@ public ProducerFactory<String, String> producerFactory() {
592
592
return new DefaultKafkaProducerFactory <>(configProps );
593
593
}
594
594
595
- @ Bean
595
+ @ Bean ( "customKafkaTemplate" )
596
596
public KafkaTemplate <String , String > kafkaTemplate () {
597
597
return new KafkaTemplate <>(producerFactory ());
598
598
}
0 commit comments