Integration Made Easy:
Dovetail 4.15: Scripting changes
The Dovetail integration platform comes with extensive support for expressions and scripting. The languages used are:
- Simple language
- XSLT
- JsonPath
- Velocity
- Groovy
- JavaScript
With the introduction of the new backend, we also upgraded some of these languages to newer versions. This is for both new functionality and security reasons. I want to highlight three of them here to see how they affect development flows.
As always your own code is your own responsibility. It’s thus good to test if scripts are still working or the changes needs to be made. In this blog, we show some points to think of.
Simple Language
The simple language of Camel 3 is largely backwards compatible with Camel 2. Changes we identified will be updated during migration. This means the simple expressions should work out-of-the-box. There are some new possibilities in Camel 3 that are nice to know about. Think of:
- Convert XML or JSON body to one line or the opposite to pretty print.
- Show the history of a message (technical route of the message). This can be useful in the error route.
- GUID: Create a new GUID in a simple expression, instead of using Groovy or JavaScript code.
Check the Camel 3 documentation for all possibilities:
Groovy Language
Dovetail has used Groovy from the start. The current version is 2.5, but from Dovetail 4.15 we upgraded Groovy to version 3. For most simple scripts nothing needs to be changed, but for more advanced script you may need to adjust the code to Groovy 3 as stated in the release notes.
Note that in the next version we plan to upgrade to Groovy 4 (expected in Dovetail 4.16.x). Upgrade path will be similar.
JavaScript Language
For JavaScript code, more changes are needed. The reason for this is more technical. Originally, both Java and JavaScript were released in 1995. Despite their names, they have nothing to do with each other. Java is a general purpose programming language that runs on a Java Virtual Machine. JavaScript is designed to run in the browser to execute the logic of web pages.
To complicate matters, two years after its release, Mozilla, the inventor of JavaScript, provided an implementation that allowed JavaScript to run on the Java Virtual Machine. This implementation was called Rhino. In 2011, Oracle replaced this implementation with a new engine called Nashorn. This became the default for Java.
In the current Dovetail, JavaScript’s are executed by the Nashorn engine. However, the Nashorn engine was deprecated by Oracle a few years ago. And then removed from Java altogether. The Camel framework also dropped all support for JavaScript. Only recently has Oracle started supporting JavaScript again with their new GraalVM project.
Fortunately, because of this new engine you can still run JavaScript on the new version of Dovetail. However, the engine works a little differently. Details can be found in the Scripts migration guide on Academy:
Conclusion
For most use cases, like Velocity, XSLT, XPath, JsonPath and Simple, scripting, are expected to work out-of-the-box. Groovy and JavaScript need some special attention and testing as mentioned in the scripts migration guide.