Created
September 4, 2022 14:06
-
-
Save mateusalxd/0a341764a48200d9da1d69ba4cc21f68 to your computer and use it in GitHub Desktop.
Apache Camel - JSLT - Merge objects
This file contains 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 com.example.colector.datasource | |
import org.apache.camel.builder.RouteBuilder | |
import org.springframework.stereotype.Component | |
@Component | |
class JsltExample : RouteBuilder() { | |
override fun configure() { | |
from("timer:?repeatCount=1") | |
.routeId("jsltExample") | |
.removeHeaders("*") | |
.process { | |
it.message.body = """{"id":1,"description":"Test"}""" | |
} | |
.setHeader("additional", constant("extra1")) | |
.setHeader("additional2", constant("extra2")) | |
.to("jslt:file:test.jslt") | |
.log("\${body}") | |
} | |
} |
This file contains 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
{"id":1,"description":"Test","additional":"extra1","additional2":"extra2"} |
This file contains 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
{ for ($headers) .key : .value } + | |
{ * : . } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment