Last active
February 21, 2023 08:36
-
-
Save soudmaijer/944fa25f4a0b746a416bbb4185b931eb to your computer and use it in GitHub Desktop.
Spring Boot application integrating Apache Camel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
camel.servlet.mapping.context-path=/* | |
camel.springboot.auto-startup=true | |
camel.rest.inline-routes = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | |
plugins { | |
id 'org.springframework.boot' version '3.0.2' | |
id 'io.spring.dependency-management' version '1.1.0' | |
id 'org.jetbrains.kotlin.jvm' version '1.7.22' | |
id 'org.jetbrains.kotlin.plugin.spring' version '1.7.22' | |
} | |
group = 'nl.sourcelabs' | |
version = '0.0.1-SNAPSHOT' | |
sourceCompatibility = '17' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
implementation 'org.apache.camel.springboot:camel-spring-boot-bom:4.0.0-M1' | |
implementation 'org.apache.camel.springboot:camel-spring-boot-starter:4.0.0-M1' | |
implementation 'org.apache.camel.springboot:camel-servlet-starter:4.0.0-M1' | |
implementation 'org.apache.camel.springboot:camel-jackson-starter:4.0.0-M1' | |
implementation 'org.springframework.boot:spring-boot-starter-web' | |
implementation 'org.jetbrains.kotlin:kotlin-reflect' | |
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' | |
testImplementation 'org.springframework.boot:spring-boot-starter-test' | |
} | |
tasks.withType(KotlinCompile) { | |
kotlinOptions { | |
freeCompilerArgs = ['-Xjsr305=strict'] | |
jvmTarget = '17' | |
} | |
} | |
tasks.named('test') { | |
useJUnitPlatform() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nl.sourcelabs.springbootcamel | |
import org.apache.camel.CamelContext | |
import org.apache.camel.builder.RouteBuilder | |
import org.springframework.boot.autoconfigure.SpringBootApplication | |
import org.springframework.boot.runApplication | |
import org.springframework.context.annotation.Bean | |
@SpringBootApplication | |
class SpringBootCamelApplication { | |
@Bean | |
fun routeBuilder(camelContext: CamelContext) = object : RouteBuilder(camelContext) { | |
override fun configure() { | |
rest("/products/{id}") | |
.get() | |
.produces("application/json") | |
.to("direct:productById") | |
from("direct:productById") | |
.log("Product with id: \${header.id} requested!") | |
.transform().simple("Product[id: \${header.id}]") | |
} | |
} | |
} | |
fun main(args: Array<String>) { | |
runApplication<SpringBootCamelApplication>(*args) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment