Java¶
This plugin allows execution of dynamically provided Java code on streamed data.
The supplied Java source must declare exactly one of the following: 1. A class with either: - public static Object process(Object input), or - public Object process(Object input) and a public no-arg constructor 2. A lambda expression compatible with a functional interface that accepts one argument and returns an object. 3. A method reference (e.g., java.lang.String::toUpperCase), though references such as this:: or super:: are not supported.
At runtime, this plugin compiles the provided Java source and invokes the process(Object input) logic for each record in the stream, returning the resulting object for downstream processing.
Note: The user-supplied code must be syntactically correct and compile without errors in other case VoltSP will close. Also, the runtime environment must have access to any external classes referenced by the user code.
.processWith(JavaProcessorConfigBuilder.builder()
.withSource(value)
.withSourceUri(value)
)
processor:
java:
source: value
sourceUri: 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-java-api</artifactId>
<version>1.7.0</version>
</dependency>
implementation group: 'org.voltdb', name: 'volt-stream-plugin-java-api', version: '1.7.0'
Properties¶
source¶
Java source code to compile and execute
Type: string
sourceUri¶
URI to a Java source file to compile and execute
Type: string
JSON Schema¶
You can validate or explore the configuration using its JSON Schema.
Usage Examples¶
Example pipeline using inline Java source.
version: 1
name: JavaProcessorExample
source:
collection: ["a", "b", "c"]
processors:
- java:
source: |
public class MyProc {
public static Object process(Object input) {
return String.valueOf(input).toUpperCase();
}
}
sink:
stdout: {}