Groovy Camel extensions
The camel-groovy module of Apache Camel extended to accept Groovy closures as arguments to the Camel DSL.
To include camel-groovy, add the following dependency to the pom.xml
file:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-groovy</artifactId>
<version>${camel-version}</version>
<!-- Exclude Groovy bundle in favor of a explicit groovy dependency -->
<!-- in order to avoid version conflicts -->
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
</exclusion>
</exclusions>
</dependency>
Now it is possible to use Groovy closures as argument to Camel processors, filters, transformers, etc.
Some examples:
// Processor closure
from('direct:input1')
.process {exchange ->
exchange.in.body = exchange.in.body.reverse()
}
.to('mock:output')
// Filter closure
from('direct:input2')
.filter {exchange ->
exchange.in.body == 'blah'
}
.to('mock:output')
// Transform closure
from('direct:input3')
.transform {exchange ->
exchange.in.body.reverse()
}