This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new c328121a351 spring-rabbitmq: initialize the Netty frame handler
classes at run time
c328121a351 is described below
commit c328121a3518c02ec94a877818f7aacd0bb3a56c
Author: jiriOndrusek-agent <[email protected]>
AuthorDate: Tue Dec 1 13:49:17 2026 +0100
spring-rabbitmq: initialize the Netty frame handler classes at run time
* Fixes #9587. spring-rabbitmq: initialize the Netty frame handler classes
at run time
Registering com.rabbitmq.client.ConnectionFactory for reflection makes
NettyFrameHandlerFactory$NettyFrameHandler reachable, and its static Netty
ByteBuf ended up in the image heap. The IT now registers ConnectionFactory
for reflection to cover this in native mode.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Test the camel.beans ConnectionFactory configuration of the issue
The spring-rabbitmq IT now defines its connection factory through
camel.beans, binding rabbitConnectionFactory.host/port/username/password
as in #9587. The bound classes are registered for reflection, as a user
has to do in native mode.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* spring-rabbitmq: register the ConnectionFactory classes for reflection
A CachingConnectionFactory defined through camel.beans, with its
rabbitConnectionFactory.* properties, now works in native mode without
quarkus.camel.native.reflection.include-patterns.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../deployment/SpringRabbitmqProcessor.java | 28 ++++++++++++++++++++++
.../rabbitmq/it/SpringRabbitmqProducers.java | 24 -------------------
.../src/main/resources/application.properties | 23 ++++++++++++++++++
3 files changed, 51 insertions(+), 24 deletions(-)
diff --git
a/extensions/spring-rabbitmq/deployment/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/deployment/SpringRabbitmqProcessor.java
b/extensions/spring-rabbitmq/deployment/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/deployment/SpringRabbitmqProcessor.java
index 13d701f73d4..fb9d978d8b7 100644
---
a/extensions/spring-rabbitmq/deployment/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/deployment/SpringRabbitmqProcessor.java
+++
b/extensions/spring-rabbitmq/deployment/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/deployment/SpringRabbitmqProcessor.java
@@ -16,10 +16,15 @@
*/
package org.apache.camel.quarkus.component.spring.rabbitmq.deployment;
+import com.rabbitmq.client.ConnectionFactory;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import
io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import
io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
+import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory;
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ChannelProxy;
import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
@@ -44,4 +49,27 @@ class SpringRabbitmqProcessor {
* It works well with string though */
"org.springframework.core.DecoratingProxy"));
}
+
+ @BuildStep
+ void
runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem>
runtimeInitializedClasses) {
+ // The Netty frame handler is not used by default (blocking IO), but
it becomes reachable
+ // when com.rabbitmq.client.ConnectionFactory is registered for
reflection.
+ // Its static Netty ByteBuf must not end up in the image heap.
+ runtimeInitializedClasses
+ .produce(new
RuntimeInitializedClassBuildItem("com.rabbitmq.client.impl.NettyFrameHandlerFactory"));
+ runtimeInitializedClasses.produce(
+ new
RuntimeInitializedClassBuildItem("com.rabbitmq.client.impl.NettyFrameHandlerFactory$NettyFrameHandler"));
+ }
+
+ @BuildStep
+ ReflectiveClassBuildItem reflectiveClasses() {
+ // Allow configuring the connection factory as a bean through
camel.beans properties,
+ // e.g. camel.beans.connectionFactory.rabbitConnectionFactory.host
+ return ReflectiveClassBuildItem.builder(
+ CachingConnectionFactory.class,
+ AbstractConnectionFactory.class,
+ ConnectionFactory.class)
+ .methods()
+ .build();
+ }
}
diff --git
a/integration-tests/spring-rabbitmq/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/it/SpringRabbitmqProducers.java
b/integration-tests/spring-rabbitmq/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/it/SpringRabbitmqProducers.java
index 34d30e84ea3..8731e5db943 100644
---
a/integration-tests/spring-rabbitmq/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/it/SpringRabbitmqProducers.java
+++
b/integration-tests/spring-rabbitmq/src/main/java/org/apache/camel/quarkus/component/spring/rabbitmq/it/SpringRabbitmqProducers.java
@@ -18,33 +18,9 @@ package
org.apache.camel.quarkus.component.spring.rabbitmq.it;
import jakarta.inject.Named;
import org.apache.camel.component.springrabbit.SpringRabbitMQComponent;
-import org.eclipse.microprofile.config.inject.ConfigProperty;
-import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
-import org.springframework.amqp.rabbit.connection.ConnectionFactory;
public class SpringRabbitmqProducers {
- @ConfigProperty(name = SpringRabbitmqResource.PARAMETER_PORT)
- Integer port;
-
- @ConfigProperty(name = SpringRabbitmqResource.PARAMETER_HOSTNAME)
- String hostname;
-
- @ConfigProperty(name = SpringRabbitmqResource.PARAMETER_USERNAME)
- String usernane;
-
- @ConfigProperty(name = SpringRabbitmqResource.PARAMETER_PASSWORD)
- String password;
-
- @Named("connectionFactory")
- public ConnectionFactory produceConnectionFactory() {
- CachingConnectionFactory cf = new CachingConnectionFactory();
- cf.setUri(String.format("amqp://%s:%d", hostname, port));
- cf.setUsername(usernane);
- cf.setPassword(password);
- return cf;
- }
-
@Named("customHeaderFilterStrategySpringRabbitComponent")
public SpringRabbitMQComponent headerFilterStrategyComponent() {
SpringRabbitMQComponent comp = new SpringRabbitMQComponent();
diff --git
a/integration-tests/spring-rabbitmq/src/main/resources/application.properties
b/integration-tests/spring-rabbitmq/src/main/resources/application.properties
new file mode 100644
index 00000000000..4e2b2d553e5
--- /dev/null
+++
b/integration-tests/spring-rabbitmq/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# https://github.com/apache/camel-quarkus/issues/9587
+camel.beans.connectionFactory =
#class:org.springframework.amqp.rabbit.connection.CachingConnectionFactory
+camel.beans.connectionFactory.rabbitConnectionFactory.host =
{{camel.quarkus.spring-rabbitmq.test.hostname}}
+camel.beans.connectionFactory.rabbitConnectionFactory.port =
{{camel.quarkus.spring-rabbitmq.test.port}}
+camel.beans.connectionFactory.rabbitConnectionFactory.username =
{{camel.quarkus.spring-rabbitmq.test.username}}
+camel.beans.connectionFactory.rabbitConnectionFactory.password =
{{camel.quarkus.spring-rabbitmq.test.password}}