0

我已经在骆驼周围寻找了很长一段时间了。我已经编写了一小段代码,它将端口 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


            }
        };
    }
}

但是当我在eclipse上编译它时出现以下错误

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 都不熟悉,因此我发现很难对其进行整理。

任何建议或帮助将不胜感激。

4

1 回答 1

2

你的类应该实现RouteBuilder,而不是LoadBalancer ...

有关详细信息,请参见http://camel.apache.org/routes.html

于 2012-08-08T15:58:36.983 回答