Skip to content

Instantly share code, notes, and snippets.

@mateusalxd
Created September 4, 2022 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateusalxd/0a341764a48200d9da1d69ba4cc21f68 to your computer and use it in GitHub Desktop.
Save mateusalxd/0a341764a48200d9da1d69ba4cc21f68 to your computer and use it in GitHub Desktop.
Apache Camel - JSLT - Merge objects
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}")
}
}
{"id":1,"description":"Test","additional":"extra1","additional2":"extra2"}
{ for ($headers) .key : .value } +
{ * : . }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment