From 86775011fda444dfbf4b0590fc4c7376e838130d Mon Sep 17 00:00:00 2001 From: croway Date: Thu, 19 Nov 2026 20:28:33 +0100 Subject: [PATCH] CAMEL-26590: camel-spring-boot - Upgrade to Spring Boot 4.2.0 Spring Boot 4.2 moved the RabbitMQ auto-configuration from spring-boot-amqp to spring-boot-rabbitmq; spring-boot-starter-amqp now brings the AMQP 1.0 client and no RabbitMQ ConnectionFactory. camel-spring-rabbitmq-starter depends on spring-boot-rabbitmq so the component gets the auto-configured ConnectionFactory and AmqpAdmin. Tests: SpringRabbitMQConnectionFactoryAutowireTest checks the component uses Boot's beans; SpringRabbitMQBootConnectionFactoryIT routes a message through RabbitMQ configured only with spring.rabbitmq.* properties. json-path: Spring Boot 4.2 manages json-path 3.0.0, so the temporary pin in camel-spring-boot-dependencies (CAMEL-22857) and the "JSONPath and Spring Boot 4.1" section of the Jackson page are removed. Regenerated: - camel-spring-boot-dependencies: micrometer 1.18.0, micrometer-tracing 1.8.0; json-path no longer listed - spring-boot.json: the configuration processor now keeps the endpoint group for management.endpoint.camelroutes; properties are unchanged Requires the Camel change of CAMEL-26590 (camel-dependencies with spring-boot-version 4.2.0). --- .../camel-spring-rabbitmq-starter/pom.xml | 122 ++++++++++++++++++ ...SpringRabbitMQBootConnectionFactoryIT.java | 90 +++++++++++++ ...RabbitMQConnectionFactoryAutowireTest.java | 63 +++++++++ .../src/main/docs/spring-boot.json | 4 +- .../modules/ROOT/pages/jackson.adoc | 30 ----- .../pom.xml | 9 -- .../camel-spring-boot-dependencies/pom.xml | 19 +-- 7 files changed, 284 insertions(+), 53 deletions(-) create mode 100644 components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQBootConnectionFactoryIT.java create mode 100644 components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQConnectionFactoryAutowireTest.java diff --git a/components-starter/camel-spring-rabbitmq-starter/pom.xml b/components-starter/camel-spring-rabbitmq-starter/pom.xml index 526db7960b67..e3553e24b95d 100644 --- a/components-starter/camel-spring-rabbitmq-starter/pom.xml +++ b/components-starter/camel-spring-rabbitmq-starter/pom.xml @@ -33,6 +33,13 @@ spring-boot-starter ${spring-boot-version} + + + org.springframework.boot + spring-boot-rabbitmq + ${spring-boot-version} + org.apache.camel camel-spring-rabbitmq @@ -46,6 +53,24 @@ + + org.apache.camel + camel-test-spring-junit6 + ${camel-version} + test + + + org.apache.camel + camel-test-infra-rabbitmq + ${camel-version} + test + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot-version} + test + org.apache.camel.springboot @@ -53,4 +78,101 @@ + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + true + 600 + false + + true + ${ci.env.name} + + + + + + + + + + rabbitmq-integration-tests-docker-file + + + /var/run/docker.sock + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + + + + rabbitmq-integration-tests-docker-env + + + env.DOCKER_HOST + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + + + + rabbitmq-integration-tests-ci + + + ci.env.name + apache.org + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + + + diff --git a/components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQBootConnectionFactoryIT.java b/components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQBootConnectionFactoryIT.java new file mode 100644 index 000000000000..5a3ade540499 --- /dev/null +++ b/components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQBootConnectionFactoryIT.java @@ -0,0 +1,90 @@ +/* + * 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. + */ +package org.apache.camel.component.springrabbit.springboot; + +import org.apache.camel.EndpointInject; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.infra.rabbitmq.services.RabbitMQService; +import org.apache.camel.test.infra.rabbitmq.services.RabbitMQServiceFactory; +import org.apache.camel.test.spring.junit6.CamelSpringBootTest; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; + +/** + * Routes a message through RabbitMQ using only the {@code spring.rabbitmq.*} properties, i.e. the connection factory + * auto-configured by Spring Boot. + */ +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@CamelSpringBootTest +@SpringBootTest(classes = SpringRabbitMQBootConnectionFactoryIT.TestConfiguration.class) +@DisabledIfSystemProperty(named = "ci.env.name", matches = "github.com", + disabledReason = "Disabled on GH Action due to Docker limit") +class SpringRabbitMQBootConnectionFactoryIT { + + @RegisterExtension + static RabbitMQService service = RabbitMQServiceFactory.createSingletonService(); + + @Autowired + ProducerTemplate template; + + @EndpointInject("mock:result") + MockEndpoint mock; + + @DynamicPropertySource + static void rabbitProperties(DynamicPropertyRegistry registry) { + registry.add("spring.rabbitmq.host", service::hostname); + registry.add("spring.rabbitmq.port", service::port); + registry.add("spring.rabbitmq.username", service::username); + registry.add("spring.rabbitmq.password", service::password); + } + + @Test + void sendAndReceive() throws Exception { + mock.expectedBodiesReceived("Hello Spring Boot 4.2"); + + template.sendBody("direct:start", "Hello Spring Boot 4.2"); + + mock.assertIsSatisfied(); + } + + @Configuration + @EnableAutoConfiguration + static class TestConfiguration { + + @Bean + RouteBuilder routes() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:start").to("spring-rabbitmq:boot42?routingKey=boot42"); + from("spring-rabbitmq:boot42?queues=boot42&routingKey=boot42&autoDeclare=true").to("mock:result"); + } + }; + } + } +} diff --git a/components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQConnectionFactoryAutowireTest.java b/components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQConnectionFactoryAutowireTest.java new file mode 100644 index 000000000000..7c201354048b --- /dev/null +++ b/components-starter/camel-spring-rabbitmq-starter/src/test/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQConnectionFactoryAutowireTest.java @@ -0,0 +1,63 @@ +/* + * 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. + */ +package org.apache.camel.component.springrabbit.springboot; + +import org.apache.camel.CamelContext; +import org.apache.camel.component.springrabbit.SpringRabbitMQComponent; +import org.apache.camel.test.spring.junit6.CamelSpringBootTest; +import org.junit.jupiter.api.Test; +import org.springframework.amqp.core.AmqpAdmin; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.annotation.DirtiesContext; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The starter alone (no {@code spring-boot-starter-rabbitmq}) must give the component the {@link ConnectionFactory} + * and {@link AmqpAdmin} that Spring Boot auto-configures. No broker is needed: the connection factory connects lazily. + */ +@DirtiesContext +@CamelSpringBootTest +@SpringBootTest(classes = SpringRabbitMQConnectionFactoryAutowireTest.TestConfiguration.class) +class SpringRabbitMQConnectionFactoryAutowireTest { + + @Autowired + CamelContext context; + + @Autowired + ConnectionFactory connectionFactory; + + @Autowired + AmqpAdmin amqpAdmin; + + @Test + void componentUsesBootConnectionFactory() { + SpringRabbitMQComponent component = context.getComponent("spring-rabbitmq", SpringRabbitMQComponent.class); + + assertThat(component.getConnectionFactory()).isSameAs(connectionFactory); + assertThat(component.getAmqpAdmin()).isSameAs(amqpAdmin); + } + + @Configuration + @EnableAutoConfiguration + static class TestConfiguration { + } +} diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json b/core/camel-spring-boot/src/main/docs/spring-boot.json index ec2f3b1d9bb8..56f08a5caba7 100644 --- a/core/camel-spring-boot/src/main/docs/spring-boot.json +++ b/core/camel-spring-boot/src/main/docs/spring-boot.json @@ -156,8 +156,8 @@ }, { "name": "management.endpoint.camelroutes", - "type": "org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpointProperties", - "sourceType": "org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpointProperties" + "type": "org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint", + "sourceType": "org.apache.camel.spring.boot.actuate.endpoint.CamelRoutesEndpoint" }, { "name": "management.server.accesslog", diff --git a/docs/spring-boot/modules/ROOT/pages/jackson.adoc b/docs/spring-boot/modules/ROOT/pages/jackson.adoc index 460e6dda4a23..21bbf09dc120 100644 --- a/docs/spring-boot/modules/ROOT/pages/jackson.adoc +++ b/docs/spring-boot/modules/ROOT/pages/jackson.adoc @@ -254,33 +254,3 @@ mvn dependency:list | grep -E 'jackson-(databind|annotations)' If you override them, override both lines together and use matching release trains (for example Jackson 2.22.x with Jackson 3.2.x), because both lines share `com.fasterxml.jackson.core:jackson-annotations`. - -== JSONPath and Spring Boot 4.1 - -The JSONPath language (`camel-jsonpath-starter`) uses Jackson 3 through the `Jackson3JsonProvider` and -`Jackson3MappingProvider` of json-path 3. Spring Boot 4.1 manages json-path 2.10.0, which does not have them, and the -Spring Boot version wins over the one Camel brings. An application with a route that uses JSONPath then fails to start -with `NoClassDefFoundError: com/jayway/jsonpath/spi/json/Jackson3JsonProvider`. Spring Boot 4.2 manages json-path -3.0.0. - -With Spring Boot 4.1, use json-path 3.0.0. When the project inherits from `spring-boot-starter-parent`, set the -property: - -[source,xml] ----- - - 3.0.0 - ----- - -When the project imports the `spring-boot-dependencies` BOM, add json-path to the `dependencyManagement` section of the -project, which wins over the imported BOMs: - -[source,xml] ----- - - com.jayway.jsonpath - json-path - 3.0.0 - ----- diff --git a/tooling/camel-spring-boot-dependencies-generator/pom.xml b/tooling/camel-spring-boot-dependencies-generator/pom.xml index 005c98641e86..cff6263b3b4f 100644 --- a/tooling/camel-spring-boot-dependencies-generator/pom.xml +++ b/tooling/camel-spring-boot-dependencies-generator/pom.xml @@ -57,15 +57,6 @@ ${avro-version} - - - com.jayway.jsonpath - json-path - ${json-path-version} - - org.apache.camel diff --git a/tooling/camel-spring-boot-dependencies/pom.xml b/tooling/camel-spring-boot-dependencies/pom.xml index c30874fc1494..b481a4676c4e 100644 --- a/tooling/camel-spring-boot-dependencies/pom.xml +++ b/tooling/camel-spring-boot-dependencies/pom.xml @@ -101,11 +101,6 @@ - - com.jayway.jsonpath - json-path - 3.0.0 - com.openai openai-java @@ -295,37 +290,37 @@ io.micrometer micrometer-commons - 1.17.2 + 1.18.0 io.micrometer micrometer-observation - 1.17.2 + 1.18.0 io.micrometer micrometer-registry-jmx - 1.17.2 + 1.18.0 io.micrometer micrometer-registry-prometheus - 1.17.2 + 1.18.0 io.micrometer micrometer-tracing - 1.7.2 + 1.8.0 io.micrometer micrometer-tracing-bridge-otel - 1.7.2 + 1.8.0 io.micrometer micrometer-tracing-test - 1.7.2 + 1.8.0 io.opentelemetry.proto