Apache Camel 与 Elasticsearch 的集成

Apache Camel Integration with Elasticsearch

我正在使用 Apache Camel 和 Elasticsearch 开发一个项目,我想知道 Camel 支持哪个版本的 Elasticsearch?

我的 pom.xml 看起来像这样:

<dependencies>
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-core</artifactId>
  <version>2.18.2</version>
</dependency>

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-elasticsearch</artifactId>
  <version>2.18.2</version>
</dependency>

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-xmljson</artifactId>
  <version>2.18.2</version>
</dependency>

<dependency>
  <groupId>xom</groupId>
  <artifactId>xom</artifactId>
  <version>1.2.5</version>
</dependency>

但是当我想将文件路由到 elasticsearch 时,出现以下错误:

java.lang.IllegalStateException: Received message from unsupported version: [2.0.0] minimal compatible version is: [5.0.0]

我发现这个异常是由于节点或TransportClient使用了旧版本。所以我尝试添加 elasticsearch 依赖项:

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

但是它给了我一个新的错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/action/WriteConsistencyLevel

所以我想知道.. Apache Camel 可以使用哪个版本的 ES?

尝试向elasticsearch发送数据的代码:

XmlJsonDataFormat xmlJsonFormat = new XmlJsonDataFormat();

from("file://C:/Projects/?fileName=data.xml&charset=utf-8")
    .marshal(xmlJsonFormat)
    .to("elasticsearch://clusterES?transportAddresses=127.0.0.1:9300&operation=BULK_INDEX&indexName=xml&indexType=account");

我认为您不需要添加任何其他 pom,除了 camel-elasticsearch。您似乎更有可能在旧版本上使用 TransportClient 运行。您需要找到它并升级 TransportClient。

https://www.elastic.co/guide/en/elasticsearch/guide/current/_transport_client_versus_node_client.html

https://discuss.elastic.co/t/received-message-from-unsupported-version-2-0-0-minimal-compatible-version-is-5-0-0/64708