Execute Script Processor
The Execute Script Processor utilizes GraalVM to execute script files of a specified language. Output from a script is passed into the transaction body of a PilotFish level transaction after execution.
Processor (Adapter) Configuration Drop-Down List
Select the Execute Script tab and click on Add Processor.
Click on Add Processor
Basic Execute Script Processor Configuration Options
- Language – scripting language to run
- Script File – script file to load
- Attribute Reference – attributes object name used in the script to reference PilotFish level transaction attribute object
- Arguments – arguments to pass into the script
- Enable Debug Output – enables “FINE’ level debug logging for the selected language
Execute Script Processor Basic Configuration Options
Selecting a Language
JavaScript is included by default in the GraalVM, but you will need to install other languages to be able to run them. These will be automatically added to the Language drop-down when installed as seen below:
Select Script Language
To add a new language to your JVM, you can follow the instructions provided by GraalVM.
In a PilotFish installation, you can find the ‘gu’ tool inside the ‘jre/bin’ directory in your installation directory. If you have installed the runtime manually (typically via Apache Tomcat), you will need to install GraalVM as your JVM manually to run this processor instead of other flavors of the JDK. Click the link for the GraalVM Download
Note: ‘Experimental’ languages are not currently available on Windows platforms, so if you intend on working with Ruby, Python, R or something else, you will need to run on a Linux/Unix based OS.
Selecting Your Script
To select a script to run, you can select a file directly from the GUI by clicking the ellipse ‘…’ to the right of the configuration and navigating to your script file:
Select Script Configuration File
Alternatively, a more encapsulated approach would be to store your scripts in a directory within the Interface running the Route. In this example, it is stored in a data folder in the interface directory:
Select Script File
Attribute Reference
The ‘Attribute Reference’ field allows you to configure the reserved word within your script to directly call into PilotFish level transaction attributes. You can access primitives or even call Java methods available on Java objects. For example:
You have a transaction attribute called ‘unique_id’, which represents some UUID you have generated as a part of your route processing. To access this within the script, we can reference the attributes by the reference value given in the configuration, which is by default ‘attributes’. In a simple JavaScript example that would be accessed as follows:
attributes.getAttribute(‘unique_id’)
Arguments
The arguments table is a key/value representation of command line arguments that would be passed into the script. The key field is purely for documentation purposes and does not get passed into the program. The value of the table is what gets passed into the script. The order they are passed is from the top down in the list.
Enable Debug Output
Enabling debug output can be very verbose but may prove useful if hitting any issues when running a script. It is recommended that it only be turned on when necessary as it can potentially impact performance and fill up logs.
Conditional Execution of the Execute Script Processor
On the Conditional Execution tab, you can set additional Processor execution conditions. The transaction data dependent condition may be specified here as an enhanced expression. If this expression returns anything other than TRUE (ignore case) – this processor will be skipped. No additional configuration for this Processor is required.
Conditional Execution of the Execute Script Processor