2016-04-11 15 views
0

Amazon SQS Queueからメッセージを消費してelasticsearchに送信するApache Camelアプリケーションを開発しようとしています。 これは私のpom.xmlファイルです:私はelasticsearch 2.2.1をapache camelでどう使うことができますか

<project xmlns="http://maven.apache.org/POM/4.0.0"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.nsm.sam</groupId> 
    <artifactId>CEP_CAMEL</artifactId> 
    <version>0.0.1</version> 
    <dependencies> 
      <dependency> 
       <groupId>org.apache.camel</groupId> 
       <artifactId>camel-core</artifactId> 
       <version>2.16.3</version> 
      </dependency> 
      <dependency> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-simple</artifactId> 
       <version>1.7.5</version> 
      </dependency> 
      <dependency> 
       <groupId>org.apache.camel</groupId> 
       <artifactId>camel-aws</artifactId> 
<!--   <version>2.8.0</version> --> 
       <version>2.16.3</version> 
      </dependency> 
      <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-google-mail</artifactId> 
      <version>2.16.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-mail</artifactId> 
      <version>2.16.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-gae</artifactId> 
      <version>2.16.3</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.camel</groupId> 
      <artifactId>camel-jsonpath</artifactId> 
      <version>2.16.3</version> 
     </dependency> 
     <dependency> 
     <groupId>org.apache.camel</groupId> 
      <artifactId>camel-elasticsearch</artifactId> 
      <version>2.16.3</version> 
     </dependency> 

     <dependency> 
      <groupId>org.elasticsearch</groupId> 
      <artifactId>elasticsearch</artifactId> 
      <version>2.2.1</version> 
     </dependency> 

     </dependencies> 
    </project> 

と私の主なアプリケーション:私はelasticsearch 1.7.5とそれをしようとすると、

package com.nsm.sam.cep; 

    import java.util.Scanner; 

    import org.apache.camel.CamelContext; 
    import org.apache.camel.builder.RouteBuilder; 
    import org.apache.camel.impl.DefaultCamelContext; 
    import org.apache.camel.impl.SimpleRegistry; 

    import com.amazonaws.ClientConfiguration; 
    import com.amazonaws.auth.AWSCredentials; 
    import com.amazonaws.auth.BasicAWSCredentials; 
    import com.amazonaws.services.sqs.AmazonSQSClient; 
    import com.amazonaws.util.json.JSONException; 

    public class CEPBroker { 
    public static void main(String args[]) throws Exception { 
     final SimpleRegistry registry = new SimpleRegistry(); 
     AWSCredentials awsCredentials = new BasicAWSCredentials("nnnnnnnnnnnnnnmy acces key", "xxxxxxxxxxxxxx my secret key"); 
     ClientConfiguration clientConfiguration = new ClientConfiguration(); 

     final AmazonSQSClient client = new AmazonSQSClient(awsCredentials, clientConfiguration); 
     client.setEndpoint("url ....."); 
     registry.put("amazonclient" , client); 
     final CamelContext context = new DefaultCamelContext(registry); 
     context.addRoutes(new RouteBuilder() { 
      public void configure() throws JSONException { 
       from("aws-sqs://SAM_SQS_test?amazonSQSClient=#amazonclient") 
       //.resequence().body() 
       //.process(new MesssageProcessor()); 
       .process(new TypeProcessor()) 
       .to("elasticsearch://elasticsearch?operation=INDEX&indexName=sam_monitoring&indexType=login&port=9300&ip=127.0.0.1"); 

      } 
     }); 
     context.start(); 
     System.out.println("Press enter to stop CAMEL ..."); 
     Scanner keyboard = new Scanner(System.in); 
     keyboard.nextLine(); 
     context.stop(); 
    } 
    } 

elasticsearchのマイistalledバージョンは2.2.1

ですそれは働いている しかし2.2.1と

私にこの例外がある

[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel  2.16.3 (CamelContext: camel-1) is starting 
    [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX is enabled 
    [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 198 type converters 
    [main] INFO org.apache.camel.impl.DefaultRuntimeEndpointRegistry - Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000) 
    Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/action/support/replication/ReplicationType 
    at org.apache.camel.component.elasticsearch.ElasticsearchConstants. <clinit>(ElasticsearchConstants.java:46) 
    at org.apache.camel.component.elasticsearch.ElasticsearchConfiguration.<init> (ElasticsearchConfiguration.java:43) 
    at org.apache.camel.component.elasticsearch.ElasticsearchComponent.createEndp oint(ElasticsearchComponent.java:43) 
    at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.jav a:114) 
     at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext. java:567) 
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContext Helper.java:79) 
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.jav a:211) 
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteCont ext.java:107) 
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteCont ext.java:113) 
    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62) 
    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56) 
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:535) 
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:496) 
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:220) 
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069) 
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196) 
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:944) 
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3260) 
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2983) 
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175) 
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2814) 
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2810) 
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2833) 
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java :2810) 
    at rg.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) 
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2779) 
    at com.nsm.sam.cep.CEPBroker.main(CEPBroker.java:43) 
    Caused by: java.lang.ClassNotFoundException: org.elasticsearch.action.support.replication.ReplicationType 
     at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 27 more 

答えて

1

私はこの厳密な問題を自分で解決しました。残念ながら、elasticsearch> = 2.0

をサポートしていません2.16.xラクダはしかし、私はそのラクダ2.17.0がelasticsearch 2.3.1で動作するように見えるん確認することができます。

ラクダ2.17.0は今elasticsearch 2.0をサポートしていることを示しているrelease notesラクダ。

Elasticsearch 1.7.3から2.0.0

+0

感謝に応答するために、私は2.17.0で再試行します。 –

関連する問題