@@ -139,6 +139,8 @@ public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
139139 private static final boolean MICROMETER_PRESENT = ClassUtils .isPresent (
140140 "io.micrometer.core.instrument.MeterRegistry" , KafkaMessageListenerContainer .class .getClassLoader ());
141141
142+ private static final Map <String , Object > CONSUMER_CONFIG_DEFAULTS = ConsumerConfig .configDef ().defaultValues ();
143+
142144 private final AbstractMessageListenerContainer <K , V > thisOrParentContainer ;
143145
144146 private final TopicPartitionOffset [] topicPartitions ;
@@ -466,8 +468,6 @@ public String toString() {
466468
467469 private final class ListenerConsumer implements SchedulingAwareRunnable , ConsumerSeekCallback {
468470
469- private static final int SIXTY = 60 ;
470-
471471 private static final String UNCHECKED = "unchecked" ;
472472
473473 private static final String RAWTYPES = "rawtypes" ;
@@ -613,7 +613,7 @@ private final class ListenerConsumer implements SchedulingAwareRunnable, Consume
613613
614614 @ SuppressWarnings (UNCHECKED )
615615 ListenerConsumer (GenericMessageListener <?> listener , ListenerType listenerType ) {
616- Properties consumerProperties = new Properties ( this . containerProperties . getKafkaConsumerProperties () );
616+ Properties consumerProperties = propertiesFromProperties ( );
617617 checkGroupInstance (consumerProperties , KafkaMessageListenerContainer .this .consumerFactory );
618618 this .autoCommit = determineAutoCommit (consumerProperties );
619619 this .consumer =
@@ -694,6 +694,20 @@ else if (listener instanceof MessageListener) {
694694 this .micrometerHolder = obtainMicrometerHolder ();
695695 }
696696
697+ private Properties propertiesFromProperties () {
698+ Properties propertyOverrides = this .containerProperties .getKafkaConsumerProperties ();
699+ Properties props = new Properties ();
700+ props .putAll (propertyOverrides );
701+ Set <String > stringPropertyNames = propertyOverrides .stringPropertyNames ();
702+ // User might have provided properties as defaults
703+ stringPropertyNames .forEach ((name ) -> {
704+ if (!props .contains (name )) {
705+ props .setProperty (name , propertyOverrides .getProperty (name ));
706+ }
707+ });
708+ return props ;
709+ }
710+
697711 private void checkGroupInstance (Properties properties , ConsumerFactory <K , V > consumerFactory ) {
698712 String groupInstance = properties .getProperty (ConsumerConfig .GROUP_INSTANCE_ID_CONFIG );
699713 if (!StringUtils .hasText (groupInstance )) {
@@ -753,9 +767,9 @@ else if (timeout instanceof String) {
753767 this .logger .warn (() -> "Unexpected type: " + timeoutToLog .getClass ().getName ()
754768 + " in property '"
755769 + ConsumerConfig .MAX_POLL_INTERVAL_MS_CONFIG
756- + "'; defaulting to 30 seconds ." );
770+ + "'; using Kafka default ." );
757771 }
758- return Duration . ofSeconds ( SIXTY / 2 ). toMillis (); // Default 'max.poll.interval.ms' is 30 seconds
772+ return ( int ) CONSUMER_CONFIG_DEFAULTS . get ( ConsumerConfig . MAX_POLL_INTERVAL_MS_CONFIG );
759773 }
760774 }
761775
@@ -822,12 +836,12 @@ else if (timeout instanceof String) {
822836 this .logger .warn (() -> "Unexpected type: " + timeoutToLog .getClass ().getName ()
823837 + " in property '"
824838 + ConsumerConfig .DEFAULT_API_TIMEOUT_MS_CONFIG
825- + "'; defaulting to 60 seconds for sync commit timeouts" );
839+ + "'; defaulting to Kafka default for sync commit timeouts" );
826840 }
827- return Duration .ofSeconds (SIXTY );
841+ return Duration
842+ .ofMillis ((int ) CONSUMER_CONFIG_DEFAULTS .get (ConsumerConfig .DEFAULT_API_TIMEOUT_MS_CONFIG ));
828843 }
829844 }
830-
831845 }
832846
833847 private Object findDeserializerClass (Map <String , Object > props , boolean isValue ) {
0 commit comments