Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

ServiceMix supports Groovy which allows Groovy scripts to be used as endpoints, transformers or services. This allows you to combine the power of the Groovy scripting language with the ServiceMix JBI container and any off the shelf JBI components to create a very flexible and agile integration solution.

The GroovyComponent is an extension of the Scripting support and supports the same variable bindings.

...

Wiki Markup
{snippet:id=xmlText|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/groovy/example.xml}

As you can see the component is configured with a piece of Groovy to execute when the service is invoked. (BTW if you wanna see this script in action try the test case and XML config file.

Now we'll go through the various options which are available when working with JBI and Groovy in ServiceMix

...

Wiki Markup
{snippet:id=groovy|lang=xml|url=http://svn.apache.org/repos/asf/incubator/servicemix/trunk/common/servicemix-components/src/test/resources/org/apache/servicemix/components/cache/example.xml}

...

Groovy provides various mechanism for generating the output (whether it is the result of a service or a transformation). Which mechnism mechanism you use depends on your use case and personal preference.

...

You can return a POJO as the body of a message - which other components can either transform or the default Marshaler will figure out the right thing to do.

...