到目前为止,我使用Apache (JAVA)将数据从Apache代理路由到InfluxDB 1.8。现在,我将数据库升级到InfluxDB 2.5。
这两个InfluxDB版本在其读写API方面是不兼容的。例如,不可能注入读写所需的安全令牌。
InfluxDB 1.8需要依赖于
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>XXX</version>InfluxDB 2.5要求
<groupId>com.influxdb</groupId>
<artifactId>influxdb-client-java</artifactId>
<version>YYY</version>在Apache中,InfluxDB组件是可用的:
<groupId>org.apache.camel</groupId>
<artifactId>camel-influxdb</artifactId>
<version>ZZZ</version>它依赖于influx-client库。这是否意味着不再存在InfluxDB 2.x组件?那么,如何构建InfluxDB 2.5端点呢?
发布于 2022-11-30 14:55:43
不幸的是,进水数据库v2只在influxdb-client-java中完全支持。但是,根据文档,您可以使用InfluxDB 1.x兼容性API继续使用influxdb-java库处理流入2.X。
发布于 2022-12-02 15:52:47
最后,我构建了一个自定义Camel组件,提供了对InfluxDB 2x的本地支持。作为起点,我使用了原始Apache jar-文件的结构和代码。
对于那些想做类似事情的人来说,这是一条途径:
使用这样的POM创建一个Maven项目:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- NOTE: I would like to get rid of this camel parent and replace it with our own. didn manage yet -->
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>components</artifactId>
<version>3.19.0</version>
</parent>
<groupId>my.group.name</groupId>
<artifactId>my-component-name</artifactId>
<version>3.19.0</version>
<packaging>jar</packaging>
<name>Camel :: InfluxDBClient</name>
<description>A Camel Component</description>
<url>...</url>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
</dependency>
<!-- InfluxDB driver dependency -->
<dependency>
<groupId>com.influxdb</groupId>
<artifactId>influxdb-client-java</artifactId>
<version>${version.influx-java-driver}</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
...在Camel组件项目中创建以下方法(所有方法都基于原始的camel-进水数据库),其中前缀Influx2Db可以替换为您喜欢的东西:
在以下位置创建名为<last part of your package name>的文件:
src/main/resources/META-INF/service/<package name minus last part>/<last part of your package name>内容:
class=<package name>.Influx2DbComponent此外,在Apache Camel应用程序中,您需要spring查找路径中的Spring自动配置类(如果使用Spring),则需要使用Spring auto配置:进水(如果使用Spring):
发布于 2022-12-02 15:53:32
最后,我在一个单独的Maven项目中构建了一个自定义Camel组件,提供了对InfluxDB 2x的本地支持。作为起点,我使用了原始Apache jar-文件的结构和代码。
对于那些想做类似事情的人来说,这是一条途径:
使用这样的POM创建一个Maven项目:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- NOTE: I would like to get rid of this camel parent and replace it with our own. didn manage yet -->
<parent>
<groupId>org.apache.camel</groupId>
<artifactId>components</artifactId>
<version>3.19.0</version>
</parent>
<groupId>my.group.name</groupId>
<artifactId>my-component-name</artifactId>
<version>3.19.0</version>
<packaging>jar</packaging>
<name>Camel :: InfluxDBClient</name>
<description>A Camel Component</description>
<url>...</url>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-support</artifactId>
</dependency>
<!-- InfluxDB driver dependency -->
<dependency>
<groupId>com.influxdb</groupId>
<artifactId>influxdb-client-java</artifactId>
<version>${version.influx-java-driver}</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
...在Camel组件项目中创建以下方法(所有方法都基于原始的camel-进水数据库),其中前缀Influx2Db可以替换为您喜欢的东西:
在以下位置创建名为<last part of your package name>的文件:
src/main/resources/META-INF/service/<package name minus last part>/<last part of your package name>内容:
class=<package name>.Influx2DbComponent此外,在Apache Camel应用程序中,您需要spring查找路径中的Spring自动配置类(如果使用Spring),则需要使用Spring auto配置:进水(如果使用Spring):
https://stackoverflow.com/questions/74625810
复制相似问题