Skip to content

Instantly share code, notes, and snippets.

@jboyens
Created August 18, 2009 21:29
Show Gist options
  • Save jboyens/169991 to your computer and use it in GitHub Desktop.
Save jboyens/169991 to your computer and use it in GitHub Desktop.
A simple HTTP sink that prints any message received and replies with "Hi!"
package crap
import org.apache.camel.*;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.language.groovy.GroovyRouteBuilder;
import org.apache.camel.processor.interceptor.*
@Grab (group = 'org.apache.camel', module = 'camel-groovy', version = '2.0-M2')
@Grab (group = 'org.apache.camel', module = 'camel-jetty', version = '2.0-M2')
@Grab (group = 'org.apache.camel', module = 'camel-http', version = '2.0-M2')
@Grab (group = 'org.apache.camel', module = 'camel-core', version = '2.0-M2')
class HttpRoutes extends GroovyRouteBuilder {
public void configure() {
def printMessage = { Exchange exchange ->
if (exchange) {
println exchange.getIn().getBody(String.class)
exchange.out.body = "Hi!"
}
} as Processor;
from("jetty:http://0.0.0.0:9999/printresponse").process(printMessage);
}
}
def camelCtx = new DefaultCamelContext()
camelCtx.addRoutes(new HttpRoutes())
camelCtx.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment