-
Notifications
You must be signed in to change notification settings - Fork 340
Description
Describe the bug
I'm using Spring Cloud Stream Function Binding.
@Bean
fun foo() = Consumer<String> {
println(it)
}
This works, but setting spring.cloud.gcp.pubsub.enabled
to false
will fail Application Context startup, if this functional bean is registered in the container:
2025-06-17T09:26:52.521+02:00 WARN 51361 --- [spring-cloud-supplier-bug] [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'
2025-06-17T09:26:52.524+02:00 INFO 51361 --- [spring-cloud-supplier-bug] [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2025-06-17T09:26:52.538+02:00 ERROR 51361 --- [spring-cloud-supplier-bug] [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean of type 'org.springframework.cloud.stream.binder.Binder' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.cloud.stream.binder.Binder' in your configuration.
Process finished with exit code 1
This can be worked around by only registering the bean, if Pub/Sub is enabled, but things get nasty, if other library code registers functional beans as well. We are for instance currently introducing Micrometer's JDBC tracing instrumentation.
Datasource Micrometer's Spring Boot auto configuration will registers a DataSourceProxyConnectionIdManagerProvider
bean, which is a Supplier<ConnectionIdManager>
. Spring Cloud Function erroneously wants to bind this bean to a channel as well, leading to above mentioned error, if Pub/Sub is disabled. There's again a workaround by manually including the ConnectionIdManager provider bean in Spring clouds ineligible function definitions,
spring.cloud.function.ineligibleDefinitions=observationConnectionIdManagerProvider
but this is a) not documented and b) should really be not necessary.
So really two things here IMHO:
- Disabling Pub/Sub should not fail ApplicationContext startup
- Spring Cloud Function should not be so aggressive when trying to bind functions, but this would probably be another feature request/issue
Versions used
implementation(platform("com.google.cloud:spring-cloud-gcp-dependencies:6.2.2"))
implementation("com.google.cloud:spring-cloud-gcp-pubsub-stream-binder")
Sample
I've attached a minimal working example and added a FIXME
comment in application.yaml
, highlighting the problem.