Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions components-starter/camel-spring-rabbitmq-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<!-- auto-configures the RabbitMQ ConnectionFactory / AmqpAdmin the component autowires
(moved from spring-boot-amqp to spring-boot-rabbitmq in Spring Boot 4.2) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-rabbitmq</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-rabbitmq</artifactId>
Expand All @@ -46,11 +53,126 @@
</exclusions>
<!--END OF GENERATED CODE-->
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit6</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-infra-rabbitmq</artifactId>
<version>${camel-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-version}</version>
<scope>test</scope>
</dependency>
<!--START OF GENERATED CODE-->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-core-starter</artifactId>
</dependency>
<!--END OF GENERATED CODE-->
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<reuseForks>true</reuseForks>
<forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<systemPropertyVariables>
<visibleassertions.silence>true</visibleassertions.silence>
<ci.env.name>${ci.env.name}</ci.env.name>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<!-- activate integration test if the docker socket file is accessible -->
<profile>
<id>rabbitmq-integration-tests-docker-file</id>
<activation>
<file>
<exists>/var/run/docker.sock</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- activate integration test if the DOCKER_HOST env var is set -->
<profile>
<id>rabbitmq-integration-tests-docker-env</id>
<activation>
<property>
<name>env.DOCKER_HOST</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- activate integration test on Apache CI (Jenkins daily) -->
<profile>
<id>rabbitmq-integration-tests-ci</id>
<activation>
<property>
<name>ci.env.name</name>
<value>apache.org</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -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");
}
};
}
}
}
Original file line number Diff line number Diff line change
@@ -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 {
}
}
4 changes: 2 additions & 2 deletions core/camel-spring-boot/src/main/docs/spring-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 0 additions & 30 deletions docs/spring-boot/modules/ROOT/pages/jackson.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
<properties>
<json-path.version>3.0.0</json-path.version>
</properties>
----

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]
----
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>3.0.0</version>
</dependency>
----
9 changes: 0 additions & 9 deletions tooling/camel-spring-boot-dependencies-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@
<version>${avro-version}</version>
</dependency>

<!-- json-path (version from Camel): camel-jsonpath uses the Jackson 3 providers of json-path 3,
while Spring Boot 4.1 manages json-path 2.x, which it only uses in spring-boot-starter-test.
Remove when upgrading to Spring Boot 4.2, which manages json-path 3.0.0. -->
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>${json-path-version}</version>
</dependency>

<!-- Dependencies from Camel parent at the end -->
<dependency>
<groupId>org.apache.camel</groupId>
Expand Down
Loading
Loading