我已经在骆驼周围徘徊了一段时间了。 我已经写了这一小段代码,可以转发所有传入的请求 在8080端口到两台服务器vmxp22-sat-1:8080和vmxp22-sat-1:8080
import java.util.List;
import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.Endpoint;
import org.apache.camel.processor.loadbalancer.LoadBalancer;
public class Test implements LoadBalancer {
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
// START SNIPPET: e1
from("jetty://http://localhost:8080")
.loadBalance().roundRobin()
.to("http://vmxp22-sat-1:8080",
"http://vmxp22-sat-2:8080");
// END SNIPPET: e1
}
};
}
}
但是当我在日食上进行调整时,我得到以下错误
The type Test must implement the inherited abstract method AsyncProcessor.process(Exchange, AsyncCallback) Test.java /first_camel/src/main/java/com/mycompany/first_camel line 24 Java Problem
The type Test must implement the inherited abstract method LoadBalancer.addProcessor(Processor) Test.java /first_camel/src/main/java/com/mycompany/first_camel line 24 Java Problem
The type Test must implement the inherited abstract method LoadBalancer.getProcessors() Test.java /first_camel/src/main/java/com/mycompany/first_camel line 24 Java Problem
The type Test must implement the inherited abstract method LoadBalancer.removeProcessor(Processor) Test.java /first_camel/src/main/java/com/mycompany/first_camel line 24 Java Problem
The type Test must implement the inherited abstract method Processor.process(Exchange) Test.java /first_camel/src/main/java/com/mycompany/first_camel line 24 Java Problem
由于我是Java和Camel的新手,我发现很难解决它。
非常感谢任何建议或帮助。
答案 0 :(得分:2)
你的类应该实现RouteBuilder,而不是LoadBalancer ......
有关详细信息,请参阅http://camel.apache.org/routes.html