quarkus: IfBuildProfile doesn't work properly with messaging
Describe the bug
Create a bean which uses e.g. @Incoming
and annotate it with @IfBuildProfile
. Then run it without the build profile.
Quarkus now complains about missing configuration if the channels, and still activates them.
Expected behavior
The bean should be completely disabled. No warnings, no MQTT connection.
Actual behavior
The bean is somewhat active. Prices (from the example) don’t get generated, but the MQTT connection is active.
How to Reproduce?
Take a look at the reproducer: https://github.com/ctron/quarkus-repro-1
In a nutshell:
- Annotate all beans with
@IfBuildProfile("foo")
- Then run without the profile
foo
Output of uname -a
or ver
Linux xxx 6.0.12-300.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 8 16:58:47 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version “17.0.5” 2022-10-18
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.14.3
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (15 by maintainers)
Commits related to this issue
- Fix #29837 Add a section about BuildIfProfile and conditional channel configuration in the amqp and kafka reference guides. — committed to cescoffier/quarkus by cescoffier a year ago
- Fix #29837 Add a section about BuildIfProfile and conditional channel configuration in the amqp and kafka reference guides. (cherry picked from commit ecb8783dd3860be82866eba8e9d49a3b47f2e885) — committed to gsmet/quarkus by cescoffier a year ago
- Fix #29837 Add a section about BuildIfProfile and conditional channel configuration in the amqp and kafka reference guides. (cherry picked from commit ecb8783dd3860be82866eba8e9d49a3b47f2e885) — committed to gsmet/quarkus by cescoffier a year ago
What I meant is if these config lines are there, without profiles, the reactive messaging will create channels (
prices
incoming, andtopic-price
outgoing) and try to resolve the graph. It obviously can’t, because all beans to be removed with@IfBuildProfile
. If a bean using reactive messaging channels is conditional to the build profile, channel config should be conditional too, as in:Then both
quarkus dev
andquarkus dev -Dquarkus.profile=foo
would work as expected.BTW for configuring the connector it should be
connector=smallrye-mqtt
nottype
. (It works for your case because quarkus discovers that only mqtt is available and configures it for you).