Javascript¶
This plugin allows execution of JavaScript code on streamed data using the GraalVM JavaScript engine.
Features¶
- Execute JavaScript code on input data
- Load JavaScript code from a file or provide it inline
- Access input data from JavaScript
- Emit output data from JavaScript
The JavaScript processor can also be configured to limit script execution time.
JavaScript API¶
The JavaScript code can access the input
data passed to the processor.
The JavaScript code should define a process
function that takes the input data and returns the output data:
function process(input) {
// Process the input data
return output;
}
Security Considerations¶
The JavaScript processor runs with limited permissions by default. It cannot access the file system, network, or other system resources unless explicitly allowed.
.processWith(JavaScriptConfigBuilder.builder()
.withScript(value)
.withScriptUrl(value)
)
processor:
javascript:
script: value
scriptUrl: value
Java dependency management¶
Add this declaration to your dependency management system to access the configuration DSL for this plugin in Java.
<dependency>
<groupId>org.voltdb</groupId>
<artifactId>volt-stream-plugin-javascript-api</artifactId>
<version>1.0-20250910-124207-release-1.5.3</version>
</dependency>
implementation group: 'org.voltdb', name: 'volt-stream-plugin-javascript-api', version: '1.0-20250910-124207-release-1.5.3'
Properties¶
script
¶
JavaScript code to execute
Type: string
scriptUrl
¶
URL to a JavaScript file to execute
Type: string
Usage Examples¶
Capitalise all strings.
version: 1
name: JavaScriptProcessorExample
source:
file:
path: "input.txt"
pipeline:
processors:
- javascript:
name: "js-processor"
script: |
function process(input) {
if (typeof input === 'string') {
return input.toUpperCase();
}
return input;
}
sink:
stdout: {}