@Grab(group='postgresql', module='postgresql', version='9.1-901.jdbc4') @Grab(group="org.apache.camel", module="camel-core", version="2.9.0") @Grab(group="org.apache.camel", module="camel-http4", version="2.9.0") @Grab(group="org.slf4j", module="slf4j-simple", version="1.6.4") //@Grab(group="org.slf4j", module="slf4j-nop", version="1.6.4") import org.apache.camel.* import org.apache.camel.builder.* import org.apache.camel.impl.* ctx = new DefaultCamelContext() ctx.addRoutes(new RouteBuilder(){ void configure() { from("direct:http") .setHeader("CamelHttpMethod", constant("GET")) .to("http4://groovy.codehaus.org") .process( { exc -> println "content:" + exc.getIn().getBody().text // レスポンスコードを取得 println "response code:" + exc.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE) } as Processor ) } }) ctx.start() template = ctx.createProducerTemplate() template.sendBody("direct:http", "") ctx.stop()
動作環境
groovy 1.8.5, JDK7 Update2, Apache Camel 2.9.0
0 件のコメント:
コメントを投稿