Created
August 18, 2009 21:29
-
-
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!"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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