I encountered this issue in version 3.2.3, and it is also present in version 3.3.0-M3.
The afterSingletonsInstantiated method in KafkaTemplate retrieves the default KafkaAdmin instance (if it has not been overridden) and configures it using the producerFactory property BOOTSTRAP_SERVERS_CONFIG. However, we experienced an error when trying to send messages to Kafka due to the SECURITY_PROTOCOL_CONFIG, which defaults to PLAINTEXT instead of SSL, as required by our configuration. Below is the error we encountered while attempting to send a message:
Configure the KafkaTemplate bean using the KafkaProducerFactory and set ObservationEnabled to true.
Attempt to send a message to Kafka.
Expected Behavior
The SECURITY_PROTOCOL_CONFIG should be retrieved from the producerFactory configuration, just like BOOTSTRAP_SERVERS_CONFIG.
Workaround
We resolved this issue by overriding the default KafkaAdmin with our custom configuration. However, since this bean is used internally by KafkaTemplate, we believe that SECURITY_PROTOCOL_CONFIG should be handled in the same way as BOOTSTRAP_SERVERS_CONFIG within the KafkaTemplate configuration.
I encountered this issue in version 3.2.3, and it is also present in version 3.3.0-M3.
The
afterSingletonsInstantiated
method inKafkaTemplate
retrieves the defaultKafkaAdmin
instance (if it has not been overridden) and configures it using theproducerFactory
propertyBOOTSTRAP_SERVERS_CONFIG
. However, we experienced an error when trying to send messages to Kafka due to theSECURITY_PROTOCOL_CONFIG
, which defaults toPLAINTEXT
instead ofSSL
, as required by our configuration. Below is the error we encountered while attempting to send a message:Steps to Reproduce
KafkaTemplate
bean using theKafkaProducerFactory
and setObservationEnabled
totrue
.Expected Behavior
The
SECURITY_PROTOCOL_CONFIG
should be retrieved from theproducerFactory
configuration, just likeBOOTSTRAP_SERVERS_CONFIG
.Workaround
We resolved this issue by overriding the default
KafkaAdmin
with our custom configuration. However, since this bean is used internally byKafkaTemplate
, we believe thatSECURITY_PROTOCOL_CONFIG
should be handled in the same way asBOOTSTRAP_SERVERS_CONFIG
within theKafkaTemplate
configuration.