Skip to main content

Groovy Editor

The Groovy Editor offers a specialized interface tailored for writing, editing, and executing Groovy code seamlessly. With its intuitive design, this editor streamlines the process of coding and running your Groovy scripts. A header or property can be added to the script. If a change is made to the header or property in the script, this can be observed on the output side. When the editor is opened, the script is written into the ready-made method as stated below. The libraries to be used must be imported.

Example Script for Get or Set Header, Propert and Body
import org.apache.camel.Exchange;

def Exchange executeMessage(Exchange message) {

// get body
def body = message.getIn().getBody(String.class);

// get header from exchange
def header = message.getIn().getHeader("header name");

// get property from exchange
def property = message.getProperty("property name");


// set body
message.getIn().setBody("body value");

// set header and add to exchange
message.getIn().setHeader("header name","header value");

// set property and add to exchange
message.setProperty("property name","property value");

return message;
}

Once the Groovy script is tailored to meet the requirements and operates smoothly without errors, it can be conveniently downloaded using the designated download button for utilization within the Script Connector.