Versions Compared

Key

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

...

This page presents how to editing the route definition in groovy language through the Web Console and which DSLs have beensupported currently.

What is Groovy Renderer

Groovy Renderer is a component, which can translate a route instance in CamelContext into a route builder in groovy language. By using it, Web Console allows developers disliking prolix XML to edit or update a route using groovy.

Getting Started

Through Web Console, you can review every route in the CamelContext. After opening a route in your browser, the URL may be http://localhost:8080/routes/route1, you can choose the edit link with groovy language to update it. A Groovy Renderer groovy renderer will turn the route into groovy route definition. For example, after chooseing to edit a route defined by the following XML:

Code Block
xml
xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route id="route1" xmlns:ns2="http://camel.apache.org/schema/web" xmlns="http://camel.apache.org/schema/spring">
    <description>This is an example route which you can start, stop and modify</description>
    <from uri="seda:foo"/>
    <to uri="mock:results" id="to1"/>
</route>

The GroovyRenderer groovy renderer will translate it into a route definition as follows:

Code Block
java
java
import org.apache.camel.language.groovy.GroovyRouteBuilder;
class GroovyRoute extends GroovyRouteBuilder {
    void configure() {
        from("seda:foo").to("mock:results")
    }
}

Then we you can update the route by input new DSL DSLs into the configure method. For example, we you can change it into a Content Based Router by updating it as follows.

Code Block
java
java
class GroovyRoute extends GroovyRouteBuilder {
    void configure() {
        from("seda:a").choice().when(header("foo").isEqualTo("bar")).to("seda:b") 
            .when(header("foo").isEqualTo("cheese")).to("seda:c").otherwise().to("seda:d")
    }
}

Save it and then the route will deliver the following messages by parsing its header.

Guide for more DSLs

Though all kinds of the DSLs can be accepted to create routes, but groovy renderer can't render every details of the routes when opening them. Web Console focuses on providing a editor for developers to update a route at runtime, but won't try to provide a development environment with full support of DSL. Following is a list showing which DSLs are fully supported and which can't be.

...