A Spring Cloud Stream module that transforms messages using a script. The language of the script can be specified.
- ScriptTransformProcessorApplication
-
the Spring Boot Main Application
- ScriptTransformProcessor
-
the actual module code that interacts with message channels
- ScriptTransformProcessorProperties
-
defines the configuration properties that are available to the Script Transform Processor
-
script: the textual form of the script to run
-
language: what language is the script? e.g. groovy/js/ruby
-
variables: variable bindings as a comma delimited string of name-value pairs, e.g. 'foo=bar,baz=car'
-
variablesLocation: the location of a properties file containing custom script variable bindings
-
XD> module register --name scriptable --coordinates org.springframework.cloud.stream.module:script-transform-processor:jar:exec:1.0.0.BUILD-SNAPSHOT --type processor
XD> stream create --deploy true --name demog --definition "time | scriptable --script=\"return payload+'::'+payload\" --language=groovy | log"
XD> stream create --deploy true --name demor --definition "time | scriptable --script=\"return \"\"#{payload.upcase}\"\"\" --language=ruby | log"
XD> stream create --deploy true --name demojs --definition "time | scriptable --script=\"function double(a) {\\n return a+''+a;\\n}\\ndouble(payload);\" --language=js | log"
Python is not currently working but when it does it will look like this!
XD> stream create --deploy true --name demop --definition "time | scriptable --script=\"def concat(x,y):\\n return x+y\\nanswer = concat(\"\"hello \"\",payload)\\n\" --language=python | log"