integrate Apache Camel into Spring Boot

This commit is contained in:
Thomas Peetz
2025-07-03 17:42:30 +02:00
parent adad4f88da
commit 5df3c1c47e
6 changed files with 62 additions and 3 deletions
+6
View File
@@ -54,9 +54,13 @@ configurations {
dependencies {
implementation 'com.vaadin:vaadin-core'
implementation 'com.vaadin:vaadin-spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-artemis'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.apache.camel.springboot:camel-spring-boot-starter'
implementation 'org.apache.activemq:artemis-jakarta-client'
implementation 'org.apache.camel.springboot:camel-jms-starter'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'io.micrometer:micrometer-registry-prometheus'
@@ -78,6 +82,7 @@ dependencies {
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'com.vaadin:vaadin-testbench-junit5'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.apache.camel:camel-test-spring-junit5'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
@@ -145,6 +150,7 @@ build.dependsOn asciidoctorPdf
dependencyManagement {
imports {
mavenBom libs.vaadin.bom.get().toString()
mavenBom libs.camel.bom.get().toString()
}
}
+2
View File
@@ -19,6 +19,7 @@ cimtConventions = "1.0.0-SNAPSHOT"
springboot = "3.2.5"
springdependencies = "1.1.4"
vaadin = "24.3.8"
camel = "4.10.6"
lombok = "8.6"
gson = "2.9.0"
jackson = "2.16.1"
@@ -43,6 +44,7 @@ mail = { module = "com.sun.mail:javax.mail", version.ref ="mail" }
sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite" }
hypersistence = { module = "io.hypersistence:hypersistence-utils-hibernate-63", version.ref = "hypersistence" }
vaadin-bom = { module = "com.vaadin:vaadin-bom", version.ref = "vaadin" }
camel-bom = { module = "org.apache.camel.springboot:camel-spring-boot-bom", version.ref = "camel"}
asciidoctorGradleJvmGems = { module = "org.asciidoctor:asciidoctor-gradle-jvm-gems", version.ref= "asciidoctor" }
asciidoctorGradleJvm = { module = "org.asciidoctor:asciidoctor-gradle-jvm", version.ref= "asciidoctor" }
asciidoctorGradleJvmPdf = { module = "org.asciidoctor:asciidoctor-gradle-jvm-pdf", version.ref= "asciidoctor" }
@@ -0,0 +1,14 @@
package de.thpeetz.kontor.integration;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class ReadQueueRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("jms:queue:KontorMediaFile")
.log("${body}");
}
}
@@ -24,14 +24,29 @@ spring:
multipart:
max-file-size: 10MB
max-request-size: 10MB
artemis:
mode: native
host: 127.0.0.1
port: 61616
user: artemis
password: artemis
camel:
cloud:
enabled: true
springboot:
routes-reload-enabled: true
routes-reload-directory: routes
routes-relaod-pattern: "*.xml"
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
include: health,info,metrics,prometheus,camelroutes
endpoint:
health:
show-details: always
probes:
enabled: true
prometheus:
enabled: true
logging:
@@ -1,11 +1,30 @@
package de.thpeetz.kontor;
import org.junit.Ignore;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.concurrent.TimeUnit;
@SpringBootTest
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.NotifyBuilder;
import static org.junit.jupiter.api.Assertions.assertTrue;
@CamelSpringBootTest
@SpringBootTest(classes = Application.class)
class ApplicationTests {
@Autowired
private CamelContext camelContext;
@Test
@Ignore
public void shouldProduceMessages() throws Exception {
NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create();
assertTrue(notify.matches(10, TimeUnit.SECONDS));
}
@Test
void contextLoads() {
@@ -1,5 +1,6 @@
package de.thpeetz.kontor.media.services;
import de.thpeetz.kontor.common.views.SearchFilter;
import de.thpeetz.kontor.media.TestConstants;
import de.thpeetz.kontor.media.data.MediaFile;
import org.junit.jupiter.api.MethodOrderer;
@@ -40,7 +41,9 @@ public class MediaFileServiceTest {
@Order(3)
void testDeleteMediaFile() {
int mediaFileCount = mediaFileService.findAllMediaFiles(null).size();
List<MediaFile> mediaFileList = mediaFileService.findAllMediaFiles(TestConstants.URL);
SearchFilter searchFilter = new SearchFilter();
searchFilter.setSearchTerm(TestConstants.URL);
List<MediaFile> mediaFileList = mediaFileService.findAllMediaFiles(searchFilter);
assertEquals(1, mediaFileList.size());
mediaFileService.deleteMediaFile(mediaFileList.get(0));
assertEquals(--mediaFileCount, mediaFileService.findAllMediaFiles(null).size());