CAMEL-22760: Bridge spring.kafka.* properties to camel-kafka component#1709
CAMEL-22760: Bridge spring.kafka.* properties to camel-kafka component#1709
Conversation
When using camel-kafka-starter with Spring Boot, users previously had to duplicate their Kafka configuration under both spring.kafka.* and camel.component.kafka.* properties. This adds a SpringKafkaPropertiesAutoConfiguration that automatically bridges Spring Boot's KafkaProperties to the Camel Kafka component configuration, including: - bootstrap-servers -> brokers - security.protocol -> security-protocol - ssl.* properties (keystore, truststore, types, passwords) - consumer.group-id -> group-id - client-id - SASL properties from spring.kafka.properties map Explicit camel.component.kafka.* settings always take precedence. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
this is a good idea, a JIRA would be good so we have it there also. And add a note in the 4.19 migration guide especially if this would default happen so end users would be aware when upgrading |
|
I guess if not already exists should be an easy option to set = true or = false to turn this bridge on|off |
- Use @autoConfiguration(after/before) instead of @configuration + @AutoConfigureBefore for correct auto-configuration ordering - Add @ConditionalOnBean(KafkaProperties.class) to gracefully skip when Spring Kafka auto-config is excluded - Use per-property Binder.bind().isBound() for reliable relaxed binding support (camelCase, kebab-case, underscore) instead of Map.containsKey() - Check isSpringPropertyBound("bootstrap-servers") for bootstrap servers since KafkaProperties defaults to ["localhost:9092"] - Fix BinderKeyFormatTest to be a proper regression test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thanks for the review @davsclaus! We've addressed your feedback and also fixed several issues found during an in-depth code review: Review fixes (latest commit):
Regarding your suggestions:
|
Users can set camel.component.kafka.bridge-spring-kafka-properties=false to disable the bridge. Enabled by default. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Added the toggle in the latest commit. The bridge can be disabled with: camel.component.kafka.bridge-spring-kafka-properties=falseIt's enabled by default ( |
|
What about |
Summary
When using
camel-kafka-starterwith Spring Boot, users previously had to duplicate their Kafka configuration under bothspring.kafka.*andcamel.component.kafka.*properties. This PR adds automatic bridging so that Spring Boot's standard Kafka properties are picked up by the Camel Kafka component.Properties bridged
spring.kafka.*)camel.component.kafka.*)bootstrap-serversbrokersclient-idclient-idsecurity.protocolsecurity-protocolconsumer.group-idgroup-idssl.key-store-locationssl-keystore-locationssl.key-store-passwordssl-keystore-passwordssl.key-store-typessl-keystore-typessl.key-passwordssl-key-passwordssl.trust-store-locationssl-truststore-locationssl.trust-store-passwordssl-truststore-passwordssl.trust-store-typessl-truststore-typessl.protocolssl-protocolproperties[sasl.mechanism]sasl-mechanismproperties[sasl.jaas.config]sasl-jaas-configproperties[sasl.kerberos.service.name]sasl-kerberos-service-nameDesign
Binderto detect whichcamel.component.kafka.*properties the user explicitly setcamel.component.kafka.*settings always take precedence@AutoConfigureBefore(KafkaComponentAutoConfiguration.class)ensures bridging happens before the generated auto-configuration copies properties to the component@ConditionalOnClass(KafkaProperties.class)ensures it only activates whenspring-boot-kafkais on the classpath (optional dependency)Test plan
🤖 Generated with Claude Code