我寫了一個簡單的路由,它將得到任何http請求並將其保存在file:output中。 一旦保存了一個處理器,它將讀取所有的請求。Apache駱駝錯誤:方法進程不適用於參數
這裏是我的代碼:
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!!
請告訴我你用什麼IDE編碼,並且關於你的錯誤檢查你的處理器在新處理器中的拼寫,P應該是大寫字母。您的進口聲明也一樣。 – Sikorski 2012-08-14 15:16:58
@Sikorski我使用eclipse!我會檢查上限,並會保持更新!謝謝你的答覆隊友! – Spaniard89 2012-08-14 19:00:47
如果你使用的是eclipse,然後利用代碼完成,你不會得到這樣的問題 – Sikorski 2012-08-15 08:04:09