@Grab(group="org.apache.camel", module="camel-core", version="2.9.0") @Grab(group="org.apache.camel", module="camel-csv", 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.getShutdownStrategy().setTimeout(5) ctx.addRoutes(new RouteBuilder(){ void configure() { // CSVファイルを読み込む from("file://c:/share/camel?fileName=test.csv&noop=true") .routeId("myroute") .unmarshal().csv() .process( { exc -> for( line in exc.getIn().getBody() ){ // 2列目を出力 println line.get(1) } } as Processor ) .process( { exc -> exc.getContext().getInflightRepository().remove(exc) exc.getContext().stopRoute("myroute") } as Processor ) } }) ctx.start() while(!ctx.getRouteStatus("myroute").isStopped()){ println "waiting..." Thread.sleep(1000) }
動作環境
groovy 1.8.5, JDK7 Update1, Apache Camel 2.9.0
0 件のコメント:
コメントを投稿