2012-08-14 126 views
0

我是駱駝的新手,並且已經閱讀了駱駝的行動書。 我正在創建一個負載平衡器的項目。 此負載均衡器將通過端口8080上的SOAP消息從客戶端獲取請求。 獲取請求後,它會將這些請求轉發到後端服務器。這些後端服務器將監聽端口8080的請求。 一旦收到請求,它就會被送達,結果通過負載均衡器返回給客戶端。後端服務器使用apache tomcat。 現在我想到使用apache駱駝路由這種情況。 我下載了fuseIDE並使用camel-archtype-java創建了一個maven項目。 並寫在駱駝基本路線如下圖所示:使用apache camel和jetty進行負載均衡 - 錯誤

**MainAPP.java** 
package Catload.Loadcat; 

import org.apache.camel.main.Main; 

public class MainApp { 

    /** 
    * A main() so we can easily run these routing rules in our IDE 
    */ 
    public static void main(String... args) throws Exception { 
     Main main = new Main(); 
     main.enableHangupSupport(); 
     main.addRouteBuilder(new MyRouteBuilder()); 
     main.run(args); 
    } 

} 


**MyRoutebuilder.java** 


package Catload.Loadcat; 

import org.apache.camel.builder.RouteBuilder; 

public class MyRouteBuilder extends RouteBuilder { 

    public void configure() { 

      from("jetty://http://localhost:8080") 
      .loadBalance().roundRobin().to("http://172.168.20.119:8080","http://172.168.20.118:8080"); 
    } 

} 

現在,當我右擊MainApp.java並選擇FuseIDE運行的Java應用程序出現錯誤

Failed to create route route1: Route[[From[jetty://http://localhost:8080]] -> [LoadBalanceT... because of Failed to resolve endpoint: jetty://http://localhost:8080 due to: No component found with scheme: jetty 

當我運行命令提示符這個項目作爲

mvn install 
mvn exec:java 

我收到以下錯誤信息:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (d 
efault-cli) on project Loadcat: An exception occured while executing the Java cl 
ass. null: InvocationTargetException: Failed to create route route1: Route[[From 
[jetty://http://localhost:8080]] -> [LoadBalanceT... because of Failed to resolv 
e endpoint: jetty://http://localhost:8080 due to: No component found with scheme 
: jetty -> [Help 1] 

我的POM文件是如下

<dependencies> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-core</artifactId> 
     <version>2.9.0.fuse-7-061</version> 
    </dependency> 
    <!-- logging --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.6.1</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.6.1</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.16</version> 
    </dependency> 

    <!-- testing --> 
    <dependency> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-test</artifactId> 
     <version>2.9.0.fuse-7-061</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.mortbay.jetty</groupId> 
     <artifactId>jetty-maven-plugin</artifactId>  
     <version>8.0.1.v20110908</version> 
    </dependency> 
    </dependencies> 

    <build> 
    <defaultGoal>install</defaultGoal> 

    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
     </plugin> 

     <plugin> 
      <groupId>org.mortbay.jetty</groupId> 
      <artifactId>maven-jetty-plugin</artifactId> 
      <version>6.1.7</version> 
     </plugin> 


     <!-- allows the route to be ran via 'mvn camel:run' --> 
     <plugin> 
     <groupId>org.apache.camel</groupId> 
     <artifactId>camel-maven-plugin</artifactId> 
     <version>2.9.0.fuse-7-061</version> 
     </plugin> 

     <!-- Allows the example to be run via 'mvn compile exec:java' --> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>exec-maven-plugin</artifactId> 
     <version>1.2.1</version> 
     <configuration> 
      <mainClass>Catload.Loadcat.MainApp</mainClass> 
      <includePluginDependencies>false</includePluginDependencies> 
     </configuration> 
     </plugin> 

    </plugins> 
    </build> 

與保險絲源少等pluginRepositories。

我的問題是,

這是正確的,我在這裏做的事情? 此路線是否有效? 如果不是其他可能性是什麼? 駱駝可以做些什麼來支持我的項目需求? 任何幫助將非常感激。

回答

2

我解決它,通過在POM文件中添加以下依賴:

<dependency> 
<groupId>org.apache.camel</groupId> 
<artifactId>camel-jetty</artifactId> 
<version>2.10.0</version> 
</dependency> 

希望這是有幫助的。