Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Groovy component

This component for the elastic.io platform may be used to execute an arbitrary Groovy code inside your integration flow.

Available Variables

Here the list of the available variables within the context of execution.

Elastic.io Specific Functionality

Available Libraries

Here is the list of available libraries within the context of execution.

Emitting an empty object

The following code creates an empty Message to be sent to the next step in the integration flow.

new Message.Builder().build()

Emitting multiple messages

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);
} 

Calling an external REST API

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()

About

Component to to execute Groovy dynamically at runtime

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages