Fuse ESB 7.0 comes with Camel 2.9 components. Camel has groovy support from 2.89 to create predicates and expressions. There is a GroovyRouteBuilder in 2.9 that lets you build dsl in groovy, albeit with java api. This is especially un-groovy when you have to write a .process.
Until a more fluent groovy route builder comes to Fuse, Here is a helper that can make writing groovy processes.
Until a more fluent groovy route builder comes to Fuse, Here is a helper that can make writing groovy processes.
class GroovyRoutes extends GroovyRouteBuilder {
@Autowired
AuthRestTemplate restTemplate;
void configure() {
setupGroovyMethods();
from("direct:resource").routeId("groovyRouteWithProcessor")
.process{ e ->
//access json and other groovy goodness
def slurper = new JsonSlurper()
// do groovy magic with them
}
.to("mock:result");
}
def setupGroovyMethods(){
//setup expandos for later ease
org.apache.camel.model.RouteDefinition.metaClass.process = { clo ->
delegate.process(new Processor(){
public void process(Exchange e) throws Exception {
clo.call(e)
}
});
}
}
}