Fix: Add EnvironmentPostProcessor for conditional RabbitMQ/Kafka exclusion#13
Conversation
…fka auto-configurations When neither firefly.eda.rabbit nor firefly.eda.kafka publisher/consumer properties are enabled, the corresponding Spring Boot auto-configurations are excluded at startup, preventing health check errors for unconfigured messaging infrastructure.
ancongui
left a comment
There was a problem hiding this comment.
LGTM. This is the most substantial change in the series, but well-implemented:
Architecture: Using EnvironmentPostProcessor (registered via spring.factories) is the correct approach for conditionally excluding auto-configurations early in the startup lifecycle — before bean definitions are created.
Logic: The exclusion logic correctly:
- Checks both publisher and consumer properties for each transport (RabbitMQ/Kafka)
- Respects explicit Spring Boot native configuration (
spring.rabbitmq.host,spring.kafka.bootstrap-servers) as an override - Preserves any existing
spring.autoconfigure.excludeentries - Uses
addFirstpriority so application properties can still override
pom.xml: Removing "Optional" comments from Kafka/RabbitMQ dependencies makes sense — they need to be on the compile classpath for the post-processor, with runtime exclusion now handled programmatically.
Registration: spring.factories is still the correct registration mechanism for EnvironmentPostProcessor in Spring Boot 3.x (unlike auto-configurations which migrated to .imports).
Summary
FireflyEdaEnvironmentPostProcessorthat excludes RabbitMQ and Kafka auto-configurations when neither publisher nor consumer properties are enabledapplication.ymlpropertiesTest plan