@@ -217,10 +217,10 @@ public void setApplicationEventPublisher(ApplicationEventPublisher applicationEv
217
217
public void setReplyTemplate (KafkaTemplate <?, ?> replyTemplate ) {
218
218
if (replyTemplate instanceof ReplyingKafkaOperations ) {
219
219
this .logger .warn (
220
- "The 'replyTemplate' should not be an implementation of 'ReplyingKafkaOperations'; "
221
- + "such implementations are for client-side request/reply operations; here we "
222
- + "are simply sending a reply to an incoming request so the reply container will "
223
- + "never be used and will consume unnecessary resources." );
220
+ "The 'replyTemplate' should not be an implementation of 'ReplyingKafkaOperations'; "
221
+ + "such implementations are for client-side request/reply operations; here we "
222
+ + "are simply sending a reply to an incoming request so the reply container will "
223
+ + "never be used and will consume unnecessary resources." );
224
224
}
225
225
this .replyTemplate = replyTemplate ;
226
226
}
@@ -314,7 +314,7 @@ public void afterPropertiesSet() {
314
314
public C createListenerContainer (KafkaListenerEndpoint endpoint ) {
315
315
C instance = createContainerInstance (endpoint );
316
316
JavaUtils .INSTANCE
317
- .acceptIfNotNull (endpoint .getId (), instance ::setBeanName );
317
+ .acceptIfNotNull (endpoint .getId (), instance ::setBeanName );
318
318
if (endpoint instanceof AbstractKafkaListenerEndpoint ) {
319
319
configureEndpoint ((AbstractKafkaListenerEndpoint <K , V >) endpoint );
320
320
}
@@ -327,14 +327,14 @@ public C createListenerContainer(KafkaListenerEndpoint endpoint) {
327
327
328
328
private void configureEndpoint (AbstractKafkaListenerEndpoint <K , V > aklEndpoint ) {
329
329
JavaUtils .INSTANCE
330
- .acceptIfNotNull (this .recordFilterStrategy , aklEndpoint ::setRecordFilterStrategy )
331
- .acceptIfNotNull (this .ackDiscarded , aklEndpoint ::setAckDiscarded )
332
- .acceptIfNotNull (this .retryTemplate , aklEndpoint ::setRetryTemplate )
333
- .acceptIfNotNull (this .recoveryCallback , aklEndpoint ::setRecoveryCallback )
334
- .acceptIfNotNull (this .statefulRetry , aklEndpoint ::setStatefulRetry )
335
- .acceptIfNotNull (this .batchListener , aklEndpoint ::setBatchListener )
336
- .acceptIfNotNull (this .replyTemplate , aklEndpoint ::setReplyTemplate )
337
- .acceptIfNotNull (this .replyHeadersConfigurer , aklEndpoint ::setReplyHeadersConfigurer );
330
+ .acceptIfNotNull (this .recordFilterStrategy , aklEndpoint ::setRecordFilterStrategy )
331
+ .acceptIfNotNull (this .ackDiscarded , aklEndpoint ::setAckDiscarded )
332
+ .acceptIfNotNull (this .retryTemplate , aklEndpoint ::setRetryTemplate )
333
+ .acceptIfNotNull (this .recoveryCallback , aklEndpoint ::setRecoveryCallback )
334
+ .acceptIfNotNull (this .statefulRetry , aklEndpoint ::setStatefulRetry )
335
+ .acceptIfNotNull (this .batchListener , aklEndpoint ::setBatchListener )
336
+ .acceptIfNotNull (this .replyTemplate , aklEndpoint ::setReplyTemplate )
337
+ .acceptIfNotNull (this .replyHeadersConfigurer , aklEndpoint ::setReplyHeadersConfigurer );
338
338
}
339
339
340
340
/**
@@ -356,13 +356,13 @@ protected void initializeContainer(C instance, KafkaListenerEndpoint endpoint) {
356
356
BeanUtils .copyProperties (this .containerProperties , properties , "topics" , "topicPartitions" , "topicPattern" ,
357
357
"messageListener" , "ackCount" , "ackTime" );
358
358
JavaUtils .INSTANCE
359
- .acceptIfNotNull (this .afterRollbackProcessor , instance ::setAfterRollbackProcessor )
360
- .acceptIfCondition (this .containerProperties .getAckCount () > 0 , this .containerProperties .getAckCount (),
361
- properties ::setAckCount )
362
- .acceptIfCondition (this .containerProperties .getAckTime () > 0 , this .containerProperties .getAckTime (),
363
- properties ::setAckTime )
364
- .acceptIfNotNull (this .errorHandler , instance ::setGenericErrorHandler )
365
- .acceptIfNotNull (this .missingTopicsFatal , instance .getContainerProperties ()::setMissingTopicsFatal );
359
+ .acceptIfNotNull (this .afterRollbackProcessor , instance ::setAfterRollbackProcessor )
360
+ .acceptIfCondition (this .containerProperties .getAckCount () > 0 , this .containerProperties .getAckCount (),
361
+ properties ::setAckCount )
362
+ .acceptIfCondition (this .containerProperties .getAckTime () > 0 , this .containerProperties .getAckTime (),
363
+ properties ::setAckTime )
364
+ .acceptIfNotNull (this .errorHandler , instance ::setGenericErrorHandler )
365
+ .acceptIfNotNull (this .missingTopicsFatal , instance .getContainerProperties ()::setMissingTopicsFatal );
366
366
if (endpoint .getAutoStartup () != null ) {
367
367
instance .setAutoStartup (endpoint .getAutoStartup ());
368
368
}
@@ -371,54 +371,66 @@ else if (this.autoStartup != null) {
371
371
}
372
372
instance .setRecordInterceptor (this .recordInterceptor );
373
373
JavaUtils .INSTANCE
374
- .acceptIfNotNull (this .phase , instance ::setPhase )
375
- .acceptIfNotNull (this .applicationEventPublisher , instance ::setApplicationEventPublisher )
376
- .acceptIfNotNull (endpoint .getGroupId (), instance .getContainerProperties ()::setGroupId )
377
- .acceptIfNotNull (endpoint .getClientIdPrefix (), instance .getContainerProperties ()::setClientId )
374
+ .acceptIfNotNull (this .phase , instance ::setPhase )
375
+ .acceptIfNotNull (this .applicationEventPublisher , instance ::setApplicationEventPublisher )
376
+ .acceptIfNotNull (endpoint .getGroupId (), instance .getContainerProperties ()::setGroupId )
377
+ .acceptIfNotNull (endpoint .getClientIdPrefix (), instance .getContainerProperties ()::setClientId )
378
378
.acceptIfNotNull (endpoint .getConsumerProperties (),
379
379
instance .getContainerProperties ()::setConsumerProperties );
380
380
}
381
381
382
+ /**
383
+ * {@inheritDoc}
384
+ * @deprecated in favor of {@link #createContainer(TopicPartitionOffset[])}
385
+ */
386
+ @ Deprecated
387
+ @ Override
388
+ public C createContainer (Collection <org .springframework .kafka .support .TopicPartitionInitialOffset > topicPartitions ) {
389
+ return createContainer (topicPartitions .stream ()
390
+ .map (org .springframework .kafka .support .TopicPartitionInitialOffset ::toTPO )
391
+ .toArray (TopicPartitionOffset []::new ));
392
+ }
393
+
382
394
@ Override
383
- public C createContainer (final Collection < TopicPartitionOffset > topicPartitions ) {
395
+ public C createContainer (TopicPartitionOffset ... topicsAndPartitions ) {
384
396
KafkaListenerEndpoint endpoint = new KafkaListenerEndpointAdapter () {
385
397
386
- @ Override
387
- public Collection < TopicPartitionOffset > getTopicPartitions () {
388
- return topicPartitions ;
389
- }
398
+ @ Override
399
+ public TopicPartitionOffset [] getTopicPartitionsToAssign () {
400
+ return Arrays . copyOf ( topicsAndPartitions , topicsAndPartitions . length ) ;
401
+ }
390
402
391
- };
403
+ };
392
404
C container = createContainerInstance (endpoint );
393
405
initializeContainer (container , endpoint );
394
406
return container ;
395
407
}
396
408
397
409
@ Override
398
- public C createContainer (final String ... topics ) {
410
+ public C createContainer (String ... topics ) {
399
411
KafkaListenerEndpoint endpoint = new KafkaListenerEndpointAdapter () {
400
412
401
- @ Override
402
- public Collection <String > getTopics () {
403
- return Arrays .asList (topics );
404
- }
413
+ @ Override
414
+ public Collection <String > getTopics () {
415
+ return Arrays .asList (topics );
416
+ }
405
417
406
- };
418
+ };
407
419
C container = createContainerInstance (endpoint );
408
420
initializeContainer (container , endpoint );
409
421
return container ;
410
422
}
411
423
412
424
@ Override
413
- public C createContainer (final Pattern topicPattern ) {
425
+ public C createContainer (Pattern topicPattern ) {
414
426
KafkaListenerEndpoint endpoint = new KafkaListenerEndpointAdapter () {
415
427
416
- @ Override
417
- public Pattern getTopicPattern () {
418
- return topicPattern ;
419
- }
428
+ @ Override
429
+ public Pattern getTopicPattern () {
430
+ return topicPattern ;
431
+ }
420
432
421
- };
433
+ };
422
434
C container = createContainerInstance (endpoint );
423
435
initializeContainer (container , endpoint );
424
436
return container ;
0 commit comments