-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application fails to start when using Pulsar binder in multi-binder scenario #3013
Comments
Issue observed for Springboot 3.3.2 + spring-cloud-stream 4.1.2, we tried also Springboot 3.2, 3.1 and 3.0, the same behaviour every time. |
BackgroundThe Pulsar binder currently relies on Spring Boot auto-configuration (
In fact, you can remove the Kafka 2nd binder out of this equation and reproduce the error w/ this single Pulsar binder that is specifying the environment. So why does this work for Rabbit and Kafka?The reason is that the Rabbit|KafkaBinderConfiguration import a subset of their respective Spring Boot auto-configuration directly. I highlight subset because it is frowned upon to directly rely on Spring Boot auto-configuration classes as they are not considered public API. We broke the direct dependence for Rabbit and Kafka a while back (here and here) which allowed us to include this subset of the auto-configuration for their binders. This subset of configuration does not yet exist for Spring Pulsar so when we implemented the Pulsar binder we decided to keep it simple and support a single binder in a Spring Boot Spring Pulsar application. WorkaroundsHowever, until we break the dependence on the PulsarAutoConfiguration, there are workarounds to support multi-binders for Pulsar. Note For simplicity of this example, let's assume we want 2 Pulsar binders. Pulsar1 Workaround 1
The example above becomes: spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.pulsar.PulsarAutoConfiguration
cloud:
stream:
binders:
pulsar1:
type: pulsar
environment:
spring:
main.sources: org.springframework.boot.autoconfigure.pulsar.PulsarAutoConfiguration
cloud:
stream:
pulsar:
binder:
config:
serviceUrl: pulsar://localhost:6650
adminUrl: http://localhost:8080
pulsar2:
type: pulsar
environment:
spring:
main.sources: org.springframework.boot.autoconfigure.pulsar.PulsarAutoConfiguration
cloud:
stream:
pulsar:
binder:
config:
serviceUrl: pulsar://localhost:7750
adminUrl: http://localhost:9090 Workaround 2
The example above becomes: spring:
cloud:
stream:
default-binder: pulsar
binders:
pulsar2:
type: pulsar
default-candidate: false
environment:
spring:
main.sources: org.springframework.boot.autoconfigure.pulsar.PulsarAutoConfiguration
cloud:
stream:
pulsar:
binder:
config:
serviceUrl: pulsar://localhost:7750
adminUrl: http://localhost:9090 Let us know once you give one of the above workarounds a try. Once we are done communicating on this issue I will close it and create an issue to break the dependence on the Pulsar auto-configuration (like we did previously for Kafka and Rabbit). Thanks |
Note I removed the bug label as this was known when we implemented the binder (I seemed to have amnesia on this topic until I spent about 45m digging into this issue and then it all came flooding back into my mind 😸 ). That being said, the above fact was not (and still is not) documented anywhere. I will fix that as part of this issue. |
|
@onobc is there are anything I can do to help to resolve this? |
Scenario
A Spring Boot application using SCSt w/ Pulsar binder as input and Kafka binder as an output.
Problem
App fails to start w/ following message:
Expected Behavior
Application starts with Pulsar as input binder and Kafka as output binder.
Details
The reporting user followed this guide to configure the binders w/ the following yaml:
After deleting the
environment
property from pulsar binder config above, everything is fine, but it disables the possibility of additional configuration at this level.The text was updated successfully, but these errors were encountered: