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
@@ -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());