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

Most upvoted comments

What I meant is if these config lines are there, without profiles, the reactive messaging will create channels (prices incoming, and topic-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:

%foo.mp.messaging.outgoing.topic-price...
...
%foo.mp.messaging.incoming.prices...

Then both quarkus dev and quarkus dev -Dquarkus.profile=foo would work as expected.

BTW for configuring the connector it should be connector=smallrye-mqtt not type. (It works for your case because quarkus discovers that only mqtt is available and configures it for you).