【问题标题】:Apache Camel Integration with ElasticsearchApache Camel 与 Elasticsearch 的集成
【发布时间】:2017-02-22 10:43:49
【问题描述】:

我正在使用 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:从不受支持的版本收到消息:[2.0.0] 最低兼容版本为:[5.0.0]

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

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

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

线程“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");

【问题讨论】:

  • 使用ES服务器2.4.3解决了问题!

标签: elasticsearch apache-camel elasticsearch-plugin


【解决方案1】:

我认为除了骆驼弹性搜索之外,您不需要添加任何其他 pom。您似乎更有可能在旧版本上运行 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

【讨论】:

  • 快速浏览一下camel存储库,我可以看到有两个弹性搜索模块camel-elasticsearchcamel-elasticsearch5。这可能就像替换您的依赖项一样简单。话虽如此,elasticsearch 节点客户端对版本差异非常敏感,即使是很小的差异,所以它可能仍然无法正常工作。如果可以选择使用 http 传输,那将更加健壮。
猜你喜欢
  • 1970-01-01
  • 2016-10-26
  • 2015-02-03
  • 2020-10-24
  • 1970-01-01
  • 1970-01-01
  • 2011-12-05
  • 2017-06-24
  • 2018-02-08
相关资源
最近更新 更多