Skip to content

Home

Introduction

Development

IDEs

Services

Service manager

API Explorer

Groovy services

Since v1.0, TORO Integrate has supported the use of Groovy services for building integrations. As the name implies, these services are written using Groovy. And put simply, Groovy services refer to Groovy methods.

Groovy services are ideal for creating low-level instructions. In terms of code, Groovy offers great flexibility – what you can't do in Gloop, you can most likely do in Groovy. The caveat, however, is that you must be familiar with programming concepts and the language itself.

You can write Groovy services in the form of Groovy scripts or Groovy methods within Groovy classes.

Here's a sample Groovy class. When called, the sayHello() method prints Hello, world! to the console. The sayHello(String) method, on the other hand, prints Hello, $name! to the console where the name argument substitutes $name in the GString.

1
2
3
4
5
class Greeter {
    void sayHello(String name = 'world') {
        println "Hello, $name!" 
    }
}

Here's a sample Groovy script. It prints Hello, world! to the console when run.

1
println "Hello, world!"

Like Gloop services, Groovy services can use one-liners which help make integrations easier to build. For example sending a JMS message can be done simply by:

1
2
3
public void sendMessage(String destination, String message) {
    destination.publishString(message)
}
Examples

TORO Integrate comes bundled with an examples package that contains many code snippets and working services to help get you started, including Groovy code samples.