我如何使用带有apache camel的elasticsearch 2.2.1

时间:2016-04-11 15:40:03

标签: maven elasticsearch apache-camel

我正在尝试开发一个Apache Camel应用程序,该应用程序使用来自Amazon SQS Queue的消息,然后将其发送到elasticsearch。 这是我的pom.xml文件:

document.innerHTML += '<my-content-users-list-view></my-content-users-list-view>

和我的主要申请:

   <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>

我的弹性搜索版本是2.2.1

当我使用elasticsearch 1.7.5尝试它时,它正在工作 但是用2.2.1

我有这个例外

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();
    }
  }

1 个答案:

答案 0 :(得分:1)

我自己也遇到了这个问题。不幸的是,camel 2.16.x不支持elasticsearch&gt; = 2.0

但是,我可以确认camel 2.17.0似乎与elasticsearch 2.3.1一起使用。

骆驼release notes表示camel 2.17.0现在支持elasticsearch 2.0。

  

弹性搜索从1.7.3到2.0.0