Skip to content

Conversation

ozangunalp
Copy link
Contributor

Resolves #47544

I am not sure of the impact of this change. So letting the CI run and have feedback from @mkouba, @geoand and @aureamunoz

@quarkus-bot quarkus-bot bot added the area/spring Issues relating to the Spring integration label Apr 28, 2025
@ozangunalp ozangunalp added triage/needs-feedback We are waiting for feedback. and removed area/spring Issues relating to the Spring integration labels Apr 28, 2025
@ozangunalp ozangunalp added the area/spring Issues relating to the Spring integration label Apr 28, 2025
.collect(Collectors.toSet()));
}
for (DotName scope : stereotypeScopes.keySet()) {
customScopeBuildProducer.produce(new CustomScopeBuildItem(scope));
Copy link
Contributor

@mkouba mkouba Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CustomScopeBuildItem should only be produced for custom scopes; which isn't the case here, or?

@ozangunalp Why exactly do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT the Spring DI extension is adding CDI scope annotations to classes where these Spring annotations are present.

So when it comes to other extensions adding default scope to classes containing some annotations (RM adding Dependent to classes containing Incoming/Outgoing, grpc adding Singleton to classes containing GrpcService, etc.) they can check whether custom scope is already present on the class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So the correct solution for multiple extensions trying to add an "auto" scope is to "prioritize", i.e. only one extension can win ;-).

In this particular case, I guess that Spring DI should win because of the org.springframework.stereotype.Service annotation used.

Therefore, I'd recommend to (1) rewrite the SmallRyeReactiveMessagingProcessor#transformBeanScope() to produce a transformation with lower priority (Spring DI is using the default priority of 1000). An idiomatic approach for an annotation transformer that merely adds a scope is to use the AutoAddScopeBuildItem; it handles most of the tricky parts automatically (such as declared scope annotations).

Something like:

@BuildStep
AutoAddScopeBuildItem autoAddScope() {
   return AutoAddScopeBuildItem.builder()
      .containsAnnotations(INCOMING, OUTGOING, CHANNEL) 
      .defaultScope(BuiltinScope.DEPENDENT)
      .build();
}

However, the AutoAddScopeBuildItem transformer has the priority 2000 so we need to (2) modify the priority of the Spring DI's transformer as well. Or use a custom annotation transformer with lower priority instead of AutoAddScopeBuildItem.

@quarkus-bot

This comment has been minimized.

@ozangunalp
Copy link
Contributor Author

I need to adapt the IT I modified so see if it works. Obviously container runtime is not available on windows tests.


@Override
public int priority() {
return 500;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to add a comment that the value is 500 because the Spring DI's annotation transformer has the default priority of value 1000 and we want it to take precedence?

Also I would squash the changes, i.e. remove the first commit completely...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I pushed the change to run the CI. Squasing now.

@quarkus-bot

This comment has been minimized.

…saging and grpc in order to take into account previously added annotations, ex. by the spring-di

Resolves quarkusio#47544
@ozangunalp ozangunalp force-pushed the fix_spring_di_messaging_beans branch from fadfb5a to 3f7a2da Compare April 28, 2025 15:16
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 28, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 3f7a2da.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Integration Tests - JDK 17

📦 integration-tests/opentelemetry-grpc-only

io.quarkus.it.opentelemetry.grpc.HelloGrpcClientTest.testHello - History

  • java.lang.RuntimeException: Failed to start quarkus - java.lang.RuntimeException
java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.test.junit.QuarkusTestExtension.throwBootFailureException(QuarkusTestExtension.java:693)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:791)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)

@geoand geoand requested a review from mkouba April 28, 2025 16:36
@mkouba mkouba merged commit 221cdc5 into quarkusio:main Apr 29, 2025
37 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.23 - main milestone Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conflict when using quarkus-kafka-messaging and quarkus-spring-di

4 participants