-1

httpリクエストを取得してfile:outputに保存する簡単なルートを作成しました。保存されると、すべての要求を読み取るプロセッサが作成されます。

これが私のコードです:

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.processor.*;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;


public class LoadBalancer {
   public static void main(String args[]) throws Exception {
          CamelContext context = new DefaultCamelContext();

        context.addRoutes(new RouteBuilder() {

            public void configure() {
                from("jetty://http://localhost:8080")
                .to("file:output");
                from("file://output").process(new processor()
                {
                    public void process(Exchange e)
                    {
                        System.out.println("Recieved exchange:" + e.getIn());
                    }
                }
                );
                //.loadBalance().roundRobin().to("http://172.28.39.138:8080","http://172.168.20.118:8080");
            }
        }); 

        context.start();

        Thread.sleep(100000);  
        context.stop();
    }
 }

これをコンパイルすると、次のエラーが発生します。

 Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    The method process(Processor) in the type ProcessorDefinition<RouteDefinition> is not applicable for the arguments (new processor(){})
    processor cannot be resolved to a type

On the line `from("file://output").process(new processor()`



I couldn't figure out what kind of error it it.
    Am I doing anything wrong in the code?
    Any help would be very much appreciated.

    Cheers!!
4

1 に答える 1

1

インラインプロセッサは次のように記述する必要があります...

from("file://output").process(new Processor() {
    public void process(Exchange exchange) throws Exception {
        System.out.println("Recieved exchange:" + e.getIn());
   }
});
于 2012-08-14T22:59:05.150 に答える