Spring Integration components can leverage Framework’s extensive support for scripting languages. You can write scripts in your favorite Framework-supported language and invoke those scripts from its endpoints. In fact, you can use any scripting language that implements JSR-223 (Scripting for Java Platform). Some of the languages Framework supports are Groovy, Python/Jython, Ruby/JRuby, and JavaScript.
Let’s take an example of a Transformer that calls a Groovy script
for transformation. The endpoint picks up the message from the in-channel
and passes it to the position-transformer.groovy
script.
<int:transformer input-channel="in-channel" output-channel="stdout"> <int-script:script lang="groovy" location="/home/mkonda/justspring/jsi/position-transformer.groovy"/> </int:transformer>
The script will have access to the MessageHeaders
and Payload
of the Message
in its execution context via headers
and payload
variables. You can also embed your
script inline as CDATA
in your
config
file.
Get Just Spring Integration now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.