This component for the elastic.io platform may be used to execute an arbitrary Groovy code inside your integration flow.
Here the list of the available variables within the context of execution.
parameters- an instance of ExecutionParameters used to access the incoming message, step's configuration, step's snapshot or an instance of EventEmitter.logger- an instance of org.slf4j.Logger used to log inside the component
Here is the list of available libraries within the context of execution.
The following code creates an empty Message to be sent to the next step in the integration flow.
new Message.Builder().build()The following code emits two messages.
1.upto(2) {
def body = Json.createObjectBuilder().add("id", "${it}").build()
def msg = new Message.Builder().body(body).build()
parameters.getEventEmitter().emitData(msg);
} The following code sends a request to an external REST API using The JAX-RS client API. The response is packed into a Message and emitted.
def token = "${System.getenv('ELASTICIO_API_USERNAME')}:${System.getenv('ELASTICIO_API_KEY')}"
JsonObject result = ClientBuilder.newClient()
.target('http://localhost:12345')
.path('v1/objects/1')
.request(MediaType.APPLICATION_JSON_TYPE)
.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(token.getBytes("UTF-8")))
.get(JsonObject.class)
new Message.Builder().body(result).build()