This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 7ba30f4794c [Component] Add camel-influxdb2 component,support for
influxdb2.x . (#8824)
7ba30f4794c is described below
commit 7ba30f4794c01baafc55fdc4c445562eaa27c335
Author: shengzhou <[email protected]>
AuthorDate: Mon Dec 5 16:29:09 2022 +0800
[Component] Add camel-influxdb2 component,support for influxdb2.x . (#8824)
* Component: Add camel-influxdb2 component,support for influxdb2.x .
* fix some problems of #8224
---
catalog/camel-allcomponents/pom.xml | 5 +
components/camel-influxdb2/pom.xml | 77 ++++++
.../influxdb2/InfluxDb2ComponentConfigurer.java | 66 +++++
.../influxdb2/InfluxDb2EndpointConfigurer.java | 82 +++++++
.../influxdb2/InfluxDb2EndpointUriFactory.java | 76 ++++++
.../influxdb2/InfluxDbComponentConfigurer.java | 61 +++++
.../influxdb2/InfluxDbEndpointConfigurer.java | 77 ++++++
.../influxdb2/InfluxDbEndpointUriFactory.java | 76 ++++++
.../converters/CamelInfluxDb2ConvertersLoader.java | 52 ++++
.../converters/CamelInfluxDbConvertersLoader.java | 48 ++++
.../services/org/apache/camel/TypeConverterLoader | 2 +
.../services/org/apache/camel/component.properties | 7 +
.../services/org/apache/camel/component/influxdb2 | 2 +
.../apache/camel/configurer/influxdb2-component | 2 +
.../org/apache/camel/configurer/influxdb2-endpoint | 2 +
.../org/apache/camel/urifactory/influxdb2-endpoint | 2 +
.../camel/component/influxdb2/influxdb2.json | 45 ++++
.../src/main/docs/influxdb2-component.adoc | 77 ++++++
.../influxdb2/CamelInfluxDb2Exception.java | 34 +++
.../component/influxdb2/InfluxDb2Component.java | 61 +++++
.../component/influxdb2/InfluxDb2Constants.java | 36 +++
.../component/influxdb2/InfluxDb2Endpoint.java | 224 +++++++++++++++++
.../component/influxdb2/InfluxDb2Producer.java | 204 ++++++++++++++++
.../converters/CamelInfluxDb2Converters.java | 51 ++++
.../component/influxdb2/data/Measurement.java | 57 +++++
.../component/influxdb2/data/Measurements.java | 77 ++++++
.../camel/component/influxdb2/data/Points.java | 73 ++++++
.../camel/component/influxdb2/data/Record.java | 41 ++++
.../camel/component/influxdb2/data/Records.java | 78 ++++++
.../camel/component/influxdb2/enums/Operation.java | 41 ++++
.../services/org/apache/camel/component/influxdb2 | 1 +
.../component/influxdb2/AbstractInfluxDbTest.java | 38 +++
.../influxdb2/InfluxDb2ProducerPingTest.java | 57 +++++
.../component/influxdb2/InfluxDb2ProducerTest.java | 266 +++++++++++++++++++++
.../converters/CamelInfluxDbConverterTest.java | 106 ++++++++
.../src/test/resources/influxdb2.test.properties | 20 ++
.../src/test/resources/log4j2.properties | 27 +++
components/pom.xml | 1 +
parent/pom.xml | 6 +
39 files changed, 2258 insertions(+)
diff --git a/catalog/camel-allcomponents/pom.xml
b/catalog/camel-allcomponents/pom.xml
index b9f2284704f..df0989d51d5 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -888,6 +888,11 @@
<artifactId>camel-influxdb</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-influxdb2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-iota</artifactId>
diff --git a/components/camel-influxdb2/pom.xml
b/components/camel-influxdb2/pom.xml
new file mode 100644
index 00000000000..8c87b47f942
--- /dev/null
+++ b/components/camel-influxdb2/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>3.20.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-influxdb2</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: InfluxDB2</name>
+ <description>Camel InfluxDB2 component</description>
+
+
+ <properties>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-support</artifactId>
+ </dependency>
+
+
+ <!--InfluxDb-->
+ <dependency>
+ <groupId>com.influxdb</groupId>
+ <artifactId>influxdb-client-java</artifactId>
+ <version>${influx-client-java-driver-version}</version>
+ </dependency>
+
+ <!-- testing -->
+ <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>
+
+ </dependencies>
+
+</project>
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2ComponentConfigurer.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2ComponentConfigurer.java
new file mode 100644
index 00000000000..35747e94482
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2ComponentConfigurer.java
@@ -0,0 +1,66 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class InfluxDb2ComponentConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ InfluxDb2Component target = (InfluxDb2Component) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled":
target.setAutowiredEnabled(property(camelContext, boolean.class, value));
return true;
+ case "influxdbclient":
+ case "influxDBClient": target.setInfluxDBClient(property(camelContext,
com.influxdb.client.InfluxDBClient.class, value)); return true;
+ case "lazystartproducer":
+ case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public String[] getAutowiredNames() {
+ return new String[]{"influxDBClient"};
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return boolean.class;
+ case "influxdbclient":
+ case "influxDBClient": return com.influxdb.client.InfluxDBClient.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ InfluxDb2Component target = (InfluxDb2Component) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "influxdbclient":
+ case "influxDBClient": return target.getInfluxDBClient();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ default: return null;
+ }
+ }
+}
+
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2EndpointConfigurer.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2EndpointConfigurer.java
new file mode 100644
index 00000000000..568d2d133ac
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2EndpointConfigurer.java
@@ -0,0 +1,82 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class InfluxDb2EndpointConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ InfluxDb2Endpoint target = (InfluxDb2Endpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autocreatebucket":
+ case "autoCreateBucket":
target.setAutoCreateBucket(property(camelContext, boolean.class, value));
return true;
+ case "autocreateorg":
+ case "autoCreateOrg": target.setAutoCreateOrg(property(camelContext,
boolean.class, value)); return true;
+ case "bucket": target.setBucket(property(camelContext,
java.lang.String.class, value)); return true;
+ case "lazystartproducer":
+ case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "operation": target.setOperation(property(camelContext,
org.apache.camel.component.influxdb2.enums.Operation.class, value)); return
true;
+ case "org": target.setOrg(property(camelContext,
java.lang.String.class, value)); return true;
+ case "retentionpolicy":
+ case "retentionPolicy":
target.setRetentionPolicy(property(camelContext, java.lang.String.class,
value)); return true;
+ case "writeprecision":
+ case "writePrecision": target.setWritePrecision(property(camelContext,
com.influxdb.client.domain.WritePrecision.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autocreatebucket":
+ case "autoCreateBucket": return boolean.class;
+ case "autocreateorg":
+ case "autoCreateOrg": return boolean.class;
+ case "bucket": return java.lang.String.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ case "operation": return
org.apache.camel.component.influxdb2.enums.Operation.class;
+ case "org": return java.lang.String.class;
+ case "retentionpolicy":
+ case "retentionPolicy": return java.lang.String.class;
+ case "writeprecision":
+ case "writePrecision": return
com.influxdb.client.domain.WritePrecision.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ InfluxDb2Endpoint target = (InfluxDb2Endpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autocreatebucket":
+ case "autoCreateBucket": return target.isAutoCreateBucket();
+ case "autocreateorg":
+ case "autoCreateOrg": return target.isAutoCreateOrg();
+ case "bucket": return target.getBucket();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ case "operation": return target.getOperation();
+ case "org": return target.getOrg();
+ case "retentionpolicy":
+ case "retentionPolicy": return target.getRetentionPolicy();
+ case "writeprecision":
+ case "writePrecision": return target.getWritePrecision();
+ default: return null;
+ }
+ }
+}
+
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2EndpointUriFactory.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2EndpointUriFactory.java
new file mode 100644
index 00000000000..277054a5a91
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDb2EndpointUriFactory.java
@@ -0,0 +1,76 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2;
+
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.spi.EndpointUriFactory;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+public class InfluxDb2EndpointUriFactory extends
org.apache.camel.support.component.EndpointUriFactorySupport implements
EndpointUriFactory {
+
+ private static final String BASE = ":connectionBean?org=<org
name>&bucket=<bucket name>";
+
+ private static final Set<String> PROPERTY_NAMES;
+ private static final Set<String> SECRET_PROPERTY_NAMES;
+ private static final Set<String> MULTI_VALUE_PREFIXES;
+ static {
+ Set<String> props = new HashSet<>(9);
+ props.add("autoCreateBucket");
+ props.add("autoCreateOrg");
+ props.add("bucket");
+ props.add("connectionBean");
+ props.add("lazyStartProducer");
+ props.add("operation");
+ props.add("org");
+ props.add("retentionPolicy");
+ props.add("writePrecision");
+ PROPERTY_NAMES = Collections.unmodifiableSet(props);
+ SECRET_PROPERTY_NAMES = Collections.emptySet();
+ MULTI_VALUE_PREFIXES = Collections.emptySet();
+ }
+
+ @Override
+ public boolean isEnabled(String scheme) {
+ return "influxdb2".equals(scheme);
+ }
+
+ @Override
+ public String buildUri(String scheme, Map<String, Object> properties,
boolean encode) throws URISyntaxException {
+ String syntax = scheme + BASE;
+ String uri = syntax;
+
+ Map<String, Object> copy = new HashMap<>(properties);
+
+ uri = buildPathParameter(syntax, uri, "connectionBean", null, true,
copy);
+ uri = buildQueryParameters(uri, copy, encode);
+ return uri;
+ }
+
+ @Override
+ public Set<String> propertyNames() {
+ return PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> secretPropertyNames() {
+ return SECRET_PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> multiValuePrefixes() {
+ return MULTI_VALUE_PREFIXES;
+ }
+
+ @Override
+ public boolean isLenientProperties() {
+ return false;
+ }
+}
+
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbComponentConfigurer.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbComponentConfigurer.java
new file mode 100644
index 00000000000..eadd0d5398f
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbComponentConfigurer.java
@@ -0,0 +1,61 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class InfluxDbComponentConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ InfluxDb2Component target = (InfluxDb2Component) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled":
target.setAutowiredEnabled(property(camelContext, boolean.class, value));
return true;
+ case "influxdbclient":
+ case "influxDBClient": target.setInfluxDBClient(property(camelContext,
com.influxdb.client.InfluxDBClient.class, value)); return true;
+ case "lazystartproducer":
+ case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public String[] getAutowiredNames() {
+ return new String[]{"influxDBClient"};
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return boolean.class;
+ case "influxdbclient":
+ case "influxDBClient": return com.influxdb.client.InfluxDBClient.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ InfluxDb2Component target = (InfluxDb2Component) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "influxdbclient":
+ case "influxDBClient": return target.getInfluxDBClient();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ default: return null;
+ }
+ }
+}
+
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbEndpointConfigurer.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbEndpointConfigurer.java
new file mode 100644
index 00000000000..5f20e58016c
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbEndpointConfigurer.java
@@ -0,0 +1,77 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class InfluxDbEndpointConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ InfluxDb2Endpoint target = (InfluxDb2Endpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autocreatebucket":
+ case "autoCreateBucket":
target.setAutoCreateBucket(property(camelContext, boolean.class, value));
return true;
+ case "autocreateorg":
+ case "autoCreateOrg": target.setAutoCreateOrg(property(camelContext,
boolean.class, value)); return true;
+ case "bucket": target.setBucket(property(camelContext,
java.lang.String.class, value)); return true;
+ case "lazystartproducer":
+ case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "operation": target.setOperation(property(camelContext,
org.apache.camel.component.influxdb2.enums.Operation.class, value)); return
true;
+ case "org": target.setOrg(property(camelContext,
java.lang.String.class, value)); return true;
+ case "retentionpolicy":
+ case "retentionPolicy":
target.setRetentionPolicy(property(camelContext, java.lang.String.class,
value)); return true;
+ case "writeprecision":
+ case "writePrecision": target.setWritePrecision(property(camelContext,
com.influxdb.client.domain.WritePrecision.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autocreatebucket":
+ case "autoCreateBucket": return boolean.class;
+ case "autocreateorg":
+ case "autoCreateOrg": return boolean.class;
+ case "bucket": return java.lang.String.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ case "operation": return
org.apache.camel.component.influxdb2.enums.Operation.class;
+ case "org": return java.lang.String.class;
+ case "retentionpolicy":
+ case "retentionPolicy": return java.lang.String.class;
+ case "writeprecision":
+ case "writePrecision": return
com.influxdb.client.domain.WritePrecision.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ InfluxDb2Endpoint target = (InfluxDb2Endpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autocreatebucket":
+ case "autoCreateBucket": return target.isAutoCreateBucket();
+ case "autocreateorg":
+ case "autoCreateOrg": return target.isAutoCreateOrg();
+ case "bucket": return target.getBucket();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ case "operation": return target.getOperation();
+ case "org": return target.getOrg();
+ case "retentionpolicy":
+ case "retentionPolicy": return target.getRetentionPolicy();
+ case "writeprecision":
+ case "writePrecision": return target.getWritePrecision();
+ default: return null;
+ }
+ }
+}
+
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbEndpointUriFactory.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbEndpointUriFactory.java
new file mode 100644
index 00000000000..1909c23d57f
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/InfluxDbEndpointUriFactory.java
@@ -0,0 +1,76 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2;
+
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.spi.EndpointUriFactory;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+public class InfluxDbEndpointUriFactory extends
org.apache.camel.support.component.EndpointUriFactorySupport implements
EndpointUriFactory {
+
+ private static final String BASE = ":connectionBean?org=<org
name>&bucket=<bucket name>";
+
+ private static final Set<String> PROPERTY_NAMES;
+ private static final Set<String> SECRET_PROPERTY_NAMES;
+ private static final Set<String> MULTI_VALUE_PREFIXES;
+ static {
+ Set<String> props = new HashSet<>(9);
+ props.add("autoCreateBucket");
+ props.add("autoCreateOrg");
+ props.add("bucket");
+ props.add("connectionBean");
+ props.add("lazyStartProducer");
+ props.add("operation");
+ props.add("org");
+ props.add("retentionPolicy");
+ props.add("writePrecision");
+ PROPERTY_NAMES = Collections.unmodifiableSet(props);
+ SECRET_PROPERTY_NAMES = Collections.emptySet();
+ MULTI_VALUE_PREFIXES = Collections.emptySet();
+ }
+
+ @Override
+ public boolean isEnabled(String scheme) {
+ return "influxdb2".equals(scheme);
+ }
+
+ @Override
+ public String buildUri(String scheme, Map<String, Object> properties,
boolean encode) throws URISyntaxException {
+ String syntax = scheme + BASE;
+ String uri = syntax;
+
+ Map<String, Object> copy = new HashMap<>(properties);
+
+ uri = buildPathParameter(syntax, uri, "connectionBean", null, true,
copy);
+ uri = buildQueryParameters(uri, copy, encode);
+ return uri;
+ }
+
+ @Override
+ public Set<String> propertyNames() {
+ return PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> secretPropertyNames() {
+ return SECRET_PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> multiValuePrefixes() {
+ return MULTI_VALUE_PREFIXES;
+ }
+
+ @Override
+ public boolean isLenientProperties() {
+ return false;
+ }
+}
+
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDb2ConvertersLoader.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDb2ConvertersLoader.java
new file mode 100644
index 00000000000..7ae6184a65d
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDb2ConvertersLoader.java
@@ -0,0 +1,52 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2.converters;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.DeferredContextBinding;
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConversionException;
+import org.apache.camel.TypeConverterLoaderException;
+import org.apache.camel.spi.TypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+import org.apache.camel.support.SimpleTypeConverter;
+import org.apache.camel.support.TypeConverterSupport;
+import org.apache.camel.util.DoubleMap;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+@DeferredContextBinding
+public final class CamelInfluxDb2ConvertersLoader implements
TypeConverterLoader, CamelContextAware {
+
+ private CamelContext camelContext;
+
+ public CamelInfluxDb2ConvertersLoader() {
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ @Override
+ public void load(TypeConverterRegistry registry) throws
TypeConverterLoaderException {
+ registerConverters(registry);
+ }
+
+ private void registerConverters(TypeConverterRegistry registry) {
+ addTypeConverter(registry, com.influxdb.client.write.Point.class,
java.util.Map.class, false,
+ (type, exchange, value) ->
org.apache.camel.component.influxdb2.converters.CamelInfluxDb2Converters.fromMapToPoint((java.util.Map)
value));
+ }
+
+ private static void addTypeConverter(TypeConverterRegistry registry,
Class<?> toType, Class<?> fromType, boolean allowNull,
SimpleTypeConverter.ConversionMethod method) {
+ registry.addTypeConverter(toType, fromType, new
SimpleTypeConverter(allowNull, method));
+ }
+
+}
diff --git
a/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDbConvertersLoader.java
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDbConvertersLoader.java
new file mode 100644
index 00000000000..a4009af2354
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDbConvertersLoader.java
@@ -0,0 +1,48 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.influxdb2.converters;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.DeferredContextBinding;
+import org.apache.camel.TypeConverterLoaderException;
+import org.apache.camel.spi.TypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+import org.apache.camel.support.SimpleTypeConverter;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+@DeferredContextBinding
+public final class CamelInfluxDbConvertersLoader implements
TypeConverterLoader, CamelContextAware {
+
+ private CamelContext camelContext;
+
+ public CamelInfluxDbConvertersLoader() {
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ @Override
+ public void load(TypeConverterRegistry registry) throws
TypeConverterLoaderException {
+ registerConverters(registry);
+ }
+
+ private void registerConverters(TypeConverterRegistry registry) {
+ addTypeConverter(registry, com.influxdb.client.write.Point.class,
java.util.Map.class, false,
+ (type, exchange, value) ->
CamelInfluxDb2Converters.fromMapToPoint((java.util.Map) value));
+ }
+
+ private static void addTypeConverter(TypeConverterRegistry registry,
Class<?> toType, Class<?> fromType, boolean allowNull,
SimpleTypeConverter.ConversionMethod method) {
+ registry.addTypeConverter(toType, fromType, new
SimpleTypeConverter(allowNull, method));
+ }
+
+}
diff --git
a/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
new file mode 100644
index 00000000000..3723407e541
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/TypeConverterLoader
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+org.apache.camel.component.influxdb2.converters.CamelInfluxDb2ConvertersLoader
diff --git
a/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/component.properties
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/component.properties
new file mode 100644
index 00000000000..84b0d2d8815
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/component.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+components=influxdb2
+groupId=org.apache.camel
+artifactId=camel-influxdb2
+version=3.20.0-SNAPSHOT
+projectName=Camel :: InfluxDB2
+projectDescription=Camel InfluxDB2 component
diff --git
a/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/component/influxdb2
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/component/influxdb2
new file mode 100644
index 00000000000..319a5275e5a
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/component/influxdb2
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.influxdb2.InfluxDb2Component
diff --git
a/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/configurer/influxdb2-component
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/configurer/influxdb2-component
new file mode 100644
index 00000000000..cc7cb34c402
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/configurer/influxdb2-component
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.influxdb2.InfluxDb2ComponentConfigurer
diff --git
a/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/configurer/influxdb2-endpoint
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/configurer/influxdb2-endpoint
new file mode 100644
index 00000000000..d70cddbc4e0
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/configurer/influxdb2-endpoint
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.influxdb2.InfluxDb2EndpointConfigurer
diff --git
a/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/urifactory/influxdb2-endpoint
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/urifactory/influxdb2-endpoint
new file mode 100644
index 00000000000..387d250183e
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/META-INF/services/org/apache/camel/urifactory/influxdb2-endpoint
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.influxdb2.InfluxDb2EndpointUriFactory
diff --git
a/components/camel-influxdb2/src/generated/resources/org/apache/camel/component/influxdb2/influxdb2.json
b/components/camel-influxdb2/src/generated/resources/org/apache/camel/component/influxdb2/influxdb2.json
new file mode 100644
index 00000000000..b6340c9eb38
--- /dev/null
+++
b/components/camel-influxdb2/src/generated/resources/org/apache/camel/component/influxdb2/influxdb2.json
@@ -0,0 +1,45 @@
+{
+ "component": {
+ "kind": "component",
+ "name": "influxdb2",
+ "title": "InfluxDB2",
+ "description": "Interact with InfluxDB, a time series database.",
+ "deprecated": false,
+ "firstVersion": "3.20.0",
+ "label": "database",
+ "javaType": "org.apache.camel.component.influxdb2.InfluxDb2Component",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-influxdb2",
+ "version": "3.20.0-SNAPSHOT",
+ "scheme": "influxdb2",
+ "extendsScheme": "",
+ "syntax": "influxdb2:connectionBean?org=<org name>&bucket=<bucket name>",
+ "async": false,
+ "api": false,
+ "consumerOnly": false,
+ "producerOnly": true,
+ "lenientProperties": false
+ },
+ "componentProperties": {
+ "influxDBClient": { "kind": "property", "displayName": "Influx DBClient",
"group": "producer", "label": "", "required": false, "type": "object",
"javaType": "com.influxdb.client.InfluxDBClient", "deprecated": false,
"autowired": true, "secret": false, "description": "The shared Influx DB to use
for all endpoints" },
+ "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start
Producer", "group": "producer", "label": "producer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Whether the producer
should be started lazy (on the first message). By starting lazy you can use
this to allow CamelContext and routes to startup in situations where a producer
may otherwise fail during star [...]
+ "autowiredEnabled": { "kind": "property", "displayName": "Autowired
Enabled", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether autowiring is
enabled. This is used for automatic autowiring options (the option must be
marked as autowired) by looking up in the registry to find if there is a single
instance of matching type, which t [...]
+ },
+ "headers": {
+ "CamelInfluxDB2MeasurementName": { "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The name of measurement", "constantName":
"org.apache.camel.component.influxdb2.InfluxDb2Constants#MEASUREMENT" },
+ "camelInfluxDB.RetentionPolicy": { "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The string that defines the retention policy to the data
created by the endpoint", "constantName":
"org.apache.camel.component.influxdb2.InfluxDb2Constants#RETENTION_POLICY" },
+ "CamelInfluxDB2WritePrecision": { "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType":
"com.influxdb.client.domain.WritePrecision", "enum": [ "ms", "s", "us", "ns" ],
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "InfluxDb Write precision.", "constantName":
"org.apache.camel.component.influxdb2.InfluxDb2Constants#WRITE_PRECISION" }
+ },
+ "properties": {
+ "connectionBean": { "kind": "path", "displayName": "Connection Bean",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "Connection to the influx2
database, of class com.influxdb.client.InfluxDBClient.class." },
+ "autoCreateBucket": { "kind": "parameter", "displayName": "Auto Create
Bucket", "group": "producer", "label": "", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Define if we want to
auto create the bucket if it's not present." },
+ "autoCreateOrg": { "kind": "parameter", "displayName": "Auto Create Org",
"group": "producer", "label": "", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "autowired": false, "secret":
false, "defaultValue": true, "description": "Define if we want to auto create
the organization if it's not present." },
+ "bucket": { "kind": "parameter", "displayName": "Bucket", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The name of the bucket where the time
series will be stored." },
+ "operation": { "kind": "parameter", "displayName": "Operation", "group":
"producer", "label": "", "required": false, "type": "object", "javaType":
"org.apache.camel.component.influxdb2.enums.Operation", "enum": [ "INSERT",
"PING" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "INSERT", "description": "Define if this operation is an insert
of ping." },
+ "org": { "kind": "parameter", "displayName": "Org", "group": "producer",
"label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "The name of the organization where the
time series will be stored." },
+ "retentionPolicy": { "kind": "parameter", "displayName": "Retention
Policy", "group": "producer", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": "default", "description": "Define the
retention policy to the data created by the endpoint." },
+ "writePrecision": { "kind": "parameter", "displayName": "Write Precision",
"group": "producer", "label": "", "required": false, "type": "object",
"javaType": "com.influxdb.client.domain.WritePrecision", "enum": [ "ms", "s",
"us", "ns" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "ms", "description": "The format or precision of time series
timestamps. see
here(https:\/\/docs.influxdata.com\/influxdb\/latest\/reference\/glossary\/#precision)"
},
+ "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start
Producer", "group": "producer (advanced)", "label": "producer,advanced",
"required": false, "type": "boolean", "javaType": "boolean", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": false,
"description": "Whether the producer should be started lazy (on the first
message). By starting lazy you can use this to allow CamelContext and routes to
startup in situations where a producer may other [...]
+ }
+}
diff --git a/components/camel-influxdb2/src/main/docs/influxdb2-component.adoc
b/components/camel-influxdb2/src/main/docs/influxdb2-component.adoc
new file mode 100644
index 00000000000..bdab8da5a0a
--- /dev/null
+++ b/components/camel-influxdb2/src/main/docs/influxdb2-component.adoc
@@ -0,0 +1,77 @@
+= InfluxDB2 Component
+:doctitle: InfluxDB2
+:shortname: influxdb2
+:artifactid: camel-influxdb2
+:description: Interact with InfluxDB, a time series database.
+:since: 3.20
+:supportlevel: Preview
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: influxdb2
+
+*Since Camel {since}*
+
+*{component-header}*
+
+This component allows you to interact with InfluxDB
+https://influxdata.com/time-series-platform/influxdb/ a time series database.
+The native body type for this component is Point (the native influxdb class),
but it can also accept Map<String, Object> as message body and it will get
converted to Point.class, please note that the map must contain an element with
InfluxDbConstants.MEASUREMENT_NAME as key.
+
+Additionally of course you may register your own Converters to your data type
to Point, or use the (un)marshalling tools provided by camel.
+
+Maven users will need to add the following dependency to their `pom.xml`
+for this component:
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-influxdb2</artifactId>
+ <version>x.x.x</version>
+ <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+== URI format
+
+-------------------------------
+influxdb2://connectionBean?[options]
+-------------------------------
+
+The producer allows sending messages to a influxdb configured in the registry,
using the native java driver.
+
+// component-configure options: START
+
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+
+// endpoint options: END
+
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
+
+== Example
+
+Below is an example route that stores a point into the db (taking the db name
from the URI) specific key:
+
+[source,java]
+------------------------------------------------------------------------------------
+from("direct:start")
+ .to("influxdb2://connectionBean?org=<org>&bucket=<bucket>");
+------------------------------------------------------------------------------------
+[source,java]
+------------------------------------------------------------------------------------
+from("direct:start")
+ .setHeader(InfluxDbConstants.ORG, "myTestOrg")
+ .setHeader(InfluxDbConstants.BUCKET, "myTestBucket")
+ .to("influxdb2://connectionBean?");
+------------------------------------------------------------------------------------
+
+include::spring-boot:partial$starter.adoc[]
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/CamelInfluxDb2Exception.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/CamelInfluxDb2Exception.java
new file mode 100644
index 00000000000..7a7df6d8040
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/CamelInfluxDb2Exception.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+public class CamelInfluxDb2Exception extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public CamelInfluxDb2Exception(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CamelInfluxDb2Exception(String message) {
+ super(message);
+ }
+
+ public CamelInfluxDb2Exception(Throwable cause) {
+ super(cause);
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Component.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Component.java
new file mode 100644
index 00000000000..420b573dfe2
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Component.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+import java.util.Map;
+
+import com.influxdb.client.InfluxDBClient;
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.support.CamelContextHelper;
+import org.apache.camel.support.DefaultComponent;
+
[email protected]("influxdb2")
+public class InfluxDb2Component extends DefaultComponent {
+
+ @Metadata(autowired = true)
+ private InfluxDBClient influxDBClient;
+
+ public InfluxDb2Component() {
+ }
+
+ protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
+ InfluxDb2Endpoint endpoint = new InfluxDb2Endpoint(uri, this);
+ endpoint.setConnectionBean(remaining);
+ InfluxDBClient target = influxDBClient;
+ if (target == null) {
+ // if not using a shared db then lookup
+ target = CamelContextHelper.mandatoryLookup(getCamelContext(),
remaining, InfluxDBClient.class);
+ }
+ endpoint.setInfluxDBClient(target);
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+
+ public InfluxDBClient getInfluxDBClient() {
+ return influxDBClient;
+ }
+
+ /**
+ * The shared Influx DB to use for all endpoints
+ *
+ * @param influxDBClient
+ */
+ public void setInfluxDBClient(InfluxDBClient influxDBClient) {
+ this.influxDBClient = influxDBClient;
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Constants.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Constants.java
new file mode 100644
index 00000000000..10cd39aac4e
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Constants.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+import org.apache.camel.spi.Metadata;
+
+public final class InfluxDb2Constants {
+ @Metadata(description = "The name of measurement", javaType = "String")
+ public static final String MEASUREMENT = "CamelInfluxDB2MeasurementName";
+ @Metadata(description = "The string that defines the retention policy to
the data created by the endpoint",
+ javaType = "String")
+ public static final String RETENTION_POLICY =
"camelInfluxDB.RetentionPolicy";
+ public static final String ORG = "CamelInfluxDB2Org";
+ public static final String BUCKET = "CamelInfluxDB2Bucket";
+ @Metadata(description = "InfluxDb Write precision.", javaType =
"com.influxdb.client.domain.WritePrecision")
+ public static final String WRITE_PRECISION =
"CamelInfluxDB2WritePrecision";
+
+ private InfluxDb2Constants() {
+
+ }
+
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java
new file mode 100644
index 00000000000..c0f208c005d
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Endpoint.java
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+import java.util.List;
+
+import com.influxdb.client.BucketsQuery;
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.OrganizationsQuery;
+import com.influxdb.client.domain.Bucket;
+import com.influxdb.client.domain.Organization;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.exceptions.NotFoundException;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.influxdb2.enums.Operation;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Interact with <a
href="https://influxdata.com/time-series-platform/influxdb/">InfluxDB</a>, a
time series database.
+ */
+@UriEndpoint(firstVersion = "3.20.0", scheme = "influxdb2", title =
"InfluxDB2",
+ syntax = "influxdb2:connectionBean?org=<org name>&bucket=<bucket
name>", category = { Category.DATABASE },
+ producerOnly = true, headersClass = InfluxDb2Constants.class)
+public class InfluxDb2Endpoint extends DefaultEndpoint {
+ private static final Logger LOG =
LoggerFactory.getLogger(InfluxDb2Endpoint.class);
+
+ private InfluxDBClient influxDBClient;
+
+ @UriPath
+ @Metadata(required = true,
+ description = "Connection to the influx2 database, of class
com.influxdb.client.InfluxDBClient.class.")
+ private String connectionBean;
+ @UriParam
+ @Metadata(required = true, description = "The name of the organization
where the time series will be stored.")
+ private String org;
+ @UriParam
+ @Metadata(required = true, description = "The name of the bucket where the
time series will be stored.")
+ private String bucket;
+ @UriParam(defaultValue = "default", description = "Define the retention
policy to the data created by the endpoint.")
+ private String retentionPolicy = "default";
+
+ @UriParam(defaultValue = "INSERT", description = "Define if this operation
is an insert of ping.")
+ private Operation operation = Operation.INSERT;
+ @UriParam(defaultValue = "true", description = "Define if we want to auto
create the organization if it's not present.")
+ private boolean autoCreateOrg = true;
+
+ @UriParam(defaultValue = "true", description = "Define if we want to auto
create the bucket if it's not present.")
+ private boolean autoCreateBucket = true;
+
+ @UriParam(defaultValue = "ms",
+ description = "The format or precision of time series
timestamps. see
[here](https://docs.influxdata.com/influxdb/latest/reference/glossary/#precision)")
+ private WritePrecision writePrecision = WritePrecision.MS;
+ private String orgID;
+
+ public InfluxDb2Endpoint(String uri, InfluxDb2Component component) {
+ super(uri, component);
+ }
+
+ public InfluxDb2Endpoint() {
+ }
+
+ public InfluxDBClient getInfluxDBClient() {
+ return influxDBClient;
+ }
+
+ public void setInfluxDBClient(InfluxDBClient influxDBClient) {
+ this.influxDBClient = influxDBClient;
+ }
+
+ public String getConnectionBean() {
+ return connectionBean;
+ }
+
+ public void setConnectionBean(String connectionBean) {
+ this.connectionBean = connectionBean;
+ }
+
+ public String getOrg() {
+ return org;
+ }
+
+ public void setOrg(String org) {
+ this.org = org;
+ }
+
+ public String getBucket() {
+ return bucket;
+ }
+
+ public void setBucket(String bucket) {
+ this.bucket = bucket;
+ }
+
+ public String getRetentionPolicy() {
+ return retentionPolicy;
+ }
+
+ public void setRetentionPolicy(String retentionPolicy) {
+ this.retentionPolicy = retentionPolicy;
+ }
+
+ public Operation getOperation() {
+ return operation;
+ }
+
+ public void setOperation(Operation operation) {
+ this.operation = operation;
+ }
+
+ public boolean isAutoCreateOrg() {
+ return autoCreateOrg;
+ }
+
+ public void setAutoCreateOrg(boolean autoCreateOrg) {
+ this.autoCreateOrg = autoCreateOrg;
+ }
+
+ public boolean isAutoCreateBucket() {
+ return autoCreateBucket;
+ }
+
+ public void setAutoCreateBucket(boolean autoCreateBucket) {
+ this.autoCreateBucket = autoCreateBucket;
+ }
+
+ public String getOrgID() {
+ return orgID;
+ }
+
+ public void setOrgID(String orgID) {
+ this.orgID = orgID;
+ }
+
+ public WritePrecision getWritePrecision() {
+ return writePrecision;
+ }
+
+ public void setWritePrecision(WritePrecision writePrecision) {
+ this.writePrecision = writePrecision;
+ }
+
+ public Producer createProducer() throws Exception {
+ return new InfluxDb2Producer(this);
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new UnsupportedOperationException("You cannot receive messages
from this endpoint");
+ }
+
+ @Override
+ protected void doInit() throws Exception {
+ super.doInit();
+ ensureOrgExists();
+ ensureBucketExists();
+ }
+
+ private void ensureOrgExists() {
+ Organization organization = null;
+ OrganizationsQuery organizationsQuery = new OrganizationsQuery();
+ organizationsQuery.setOrg(org);
+ boolean exists = false;
+ try {
+ List<Organization> organizations =
getInfluxDBClient().getOrganizationsApi().findOrganizations(organizationsQuery);
+ if (organizations.stream().anyMatch(o -> o.getName().equals(org)))
{
+ exists = true;
+ organization = organizations.stream().filter(o ->
o.getName().equals(org)).findFirst().get();
+ }
+ } catch (NotFoundException ex) {
+ exists = false;
+ }
+ if (!exists && autoCreateOrg) {
+ LOG.debug("Organization {} doesn't exist. Creating it...", org);
+ organization =
getInfluxDBClient().getOrganizationsApi().createOrganization(org);
+ }
+ if (organization != null) {
+ setOrgID(organization.getId());
+ }
+ }
+
+ private void ensureBucketExists() {
+
+ ensureOrgExists();
+
+ boolean exists = false;
+ BucketsQuery bucketsQuery = new BucketsQuery();
+ bucketsQuery.setOrg(org);
+ bucketsQuery.setName(bucket);
+ try {
+ List<Bucket> buckets =
getInfluxDBClient().getBucketsApi().findBuckets(bucketsQuery);
+ if (buckets.stream().anyMatch(b -> b.getName().equals(bucket))) {
+ exists = true;
+ }
+ } catch (NotFoundException ex) {
+ exists = false;
+ }
+ if (!exists && autoCreateBucket) {
+ LOG.debug("Bucket {} doesn't exist. Creating it...", bucket);
+ getInfluxDBClient().getBucketsApi().createBucket(bucket,
getOrgID());
+ }
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Producer.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Producer.java
new file mode 100644
index 00000000000..639b181a764
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/InfluxDb2Producer.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+import com.influxdb.client.InfluxDBClient;
+import com.influxdb.client.WriteApi;
+import com.influxdb.client.domain.WritePrecision;
+import com.influxdb.client.write.Point;
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.component.influxdb2.data.Measurement;
+import org.apache.camel.component.influxdb2.data.Measurements;
+import org.apache.camel.component.influxdb2.data.Points;
+import org.apache.camel.component.influxdb2.data.Record;
+import org.apache.camel.component.influxdb2.data.Records;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.support.MessageHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InfluxDb2Producer extends DefaultProducer {
+ private static final Logger LOG =
LoggerFactory.getLogger(InfluxDb2Producer.class);
+ InfluxDb2Endpoint endpoint;
+
+ InfluxDBClient connection;
+
+ WriteApi writeApi;
+
+ public InfluxDb2Producer(InfluxDb2Endpoint endpoint) {
+ super(endpoint);
+ this.connection = endpoint.getInfluxDBClient();
+ this.endpoint = endpoint;
+ this.writeApi = connection.makeWriteApi();
+ }
+
+ /**
+ * Processes the message exchange
+ *
+ * @param exchange the message exchange
+ * @throws Exception if an internal processing error has occurred.
+ */
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ String orgName = calculateOrgName(exchange);
+ String bucketName = calculateBucketName(exchange);
+ WritePrecision writePrecision = calculateWritePrecision(exchange);
+ switch (endpoint.getOperation()) {
+ case INSERT:
+ doInsert(exchange, orgName, bucketName, writePrecision);
+ break;
+ case PING:
+ doPing(exchange);
+ break;
+ default:
+ throw new IllegalArgumentException("The operation " +
endpoint.getOperation() + " is not supported");
+ }
+ }
+
+ private void doInsert(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ Object body = exchange.getIn().getBody();
+ if (body instanceof Point) {
+ insertPoint(exchange, orgName, bucketName, writePrecision);
+ } else if (body instanceof Measurement) {
+ insertMeasurement(exchange, orgName, bucketName, writePrecision);
+ } else if (body instanceof Record) {
+ insertRecord(exchange, orgName, bucketName, writePrecision);
+ } else if (body instanceof Points) {
+ insertPoints(exchange, orgName, bucketName, writePrecision);
+ } else if (body instanceof Measurements) {
+ insertMeasurements(exchange, orgName, bucketName, writePrecision);
+ } else if (body instanceof Records) {
+ insertRecords(exchange, orgName, bucketName, writePrecision);
+ } else {
+ // default insert as point
+ insertPoint(exchange, orgName, bucketName, writePrecision);
+ }
+ }
+
+ private void insertPoint(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ Point point = exchange.getIn().getMandatoryBody(Point.class);
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing point {}", point.toLineProtocol());
+ }
+ writeApi.writePoint(bucketName, orgName, point);
+ } catch (Exception ex) {
+ exchange.setException(new CamelInfluxDb2Exception(ex));
+ }
+ }
+
+ private void insertMeasurement(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ Measurement measurement =
exchange.getIn().getMandatoryBody(Measurement.class);
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing measurement {}", measurement);
+ }
+ writeApi.writeMeasurement(bucketName, orgName, writePrecision,
measurement.getInfluxMeasurement());
+ } catch (Exception ex) {
+ exchange.setException(new CamelInfluxDb2Exception(ex));
+ }
+ }
+
+ private void insertRecord(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ Record record = exchange.getIn().getMandatoryBody(Record.class);
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing record {}", record);
+ }
+ writeApi.writeRecord(bucketName, orgName, writePrecision,
record.getInfluxRecord());
+ } catch (Exception ex) {
+ exchange.setException(new CamelInfluxDb2Exception(ex));
+ }
+ }
+
+ private void insertPoints(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ @SuppressWarnings("unchecked")
+ Points points = exchange.getIn().getMandatoryBody(Points.class);
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing points {}", points);
+ }
+ writeApi.writePoints(bucketName, orgName,
points.getInfluxPoints());
+ } catch (Exception ex) {
+ exchange.setException(new CamelInfluxDb2Exception(ex));
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private void insertMeasurements(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ Measurements measurements =
exchange.getIn().getMandatoryBody(Measurements.class);
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing measurements {}", measurements);
+ }
+ writeApi.writeMeasurements(bucketName, orgName, writePrecision,
measurements.getInfluxMeasurements());
+ } catch (Exception ex) {
+ exchange.setException(new CamelInfluxDb2Exception(ex));
+ }
+ }
+
+ private void insertRecords(Exchange exchange, String orgName, String
bucketName, WritePrecision writePrecision)
+ throws InvalidPayloadException {
+ Records records = exchange.getIn().getMandatoryBody(Records.class);
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Writing records {}", records);
+ }
+ writeApi.writeRecords(bucketName, orgName, writePrecision,
records.getInfluxRecords());
+ } catch (Exception ex) {
+ exchange.setException(new CamelInfluxDb2Exception(ex));
+ }
+ }
+
+ private void doPing(Exchange exchange) {
+ Boolean result = connection.ping();
+ MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
+ exchange.getMessage().setBody(result);
+ }
+
+ private String calculateOrgName(Exchange exchange) {
+ String orgName = exchange.getIn().getHeader(InfluxDb2Constants.ORG,
String.class);
+ if (ObjectHelper.isNotEmpty(orgName)) {
+ return orgName;
+ }
+ return endpoint.getOrg();
+ }
+
+ private String calculateBucketName(Exchange exchange) {
+ String bucketName =
exchange.getIn().getHeader(InfluxDb2Constants.BUCKET, String.class);
+ if (ObjectHelper.isNotEmpty(bucketName)) {
+ return bucketName;
+ }
+ return endpoint.getBucket();
+ }
+
+ private WritePrecision calculateWritePrecision(Exchange exchange) {
+ WritePrecision precision =
exchange.getIn().getHeader(InfluxDb2Constants.WRITE_PRECISION,
WritePrecision.class);
+ if (ObjectHelper.isNotEmpty(precision)) {
+ return precision;
+ }
+ return endpoint.getWritePrecision();
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDb2Converters.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDb2Converters.java
new file mode 100644
index 00000000000..203ab5d10a3
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDb2Converters.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2.converters;
+
+import java.util.Map;
+
+import com.influxdb.client.write.Point;
+import org.apache.camel.Converter;
+import org.apache.camel.component.influxdb2.CamelInfluxDb2Exception;
+import org.apache.camel.component.influxdb2.InfluxDb2Constants;
+
+/**
+ * Called after InvalidPayloadException raised.
+ */
+@Converter(generateLoader = true)
+public final class CamelInfluxDb2Converters {
+
+ private CamelInfluxDb2Converters() {
+ }
+
+ @Converter
+ public static Point fromMapToPoint(Map<String, Object> map) {
+ Object measurementName = map.get(InfluxDb2Constants.MEASUREMENT);
+ if (measurementName == null) {
+ String format = String.format("Unable to find the header for the
measurement in: %s", map.keySet().toString());
+ throw new CamelInfluxDb2Exception(format);
+ }
+
+ String measurenmentNameString = measurementName.toString();
+ Point point = Point.measurement(measurenmentNameString);
+ map.remove(InfluxDb2Constants.MEASUREMENT);
+ point.addFields(map);
+ map.put(InfluxDb2Constants.MEASUREMENT, measurementName);
+
+ return point;
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Measurement.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Measurement.java
new file mode 100644
index 00000000000..e7e538a9c21
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Measurement.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2.data;
+
+/**
+ * InfluxDb write measurement.
+ */
+public final class Measurement {
+ private Object measurement;
+
+ private Measurement(Object measurement) {
+ this.measurement = measurement;
+ }
+
+ public static Measurement fromObject(Object measurement) throws
IllegalArgumentException {
+ check(measurement);
+ return new Measurement(measurement);
+ }
+
+ /**
+ * get influxdb2 write measurement
+ *
+ * @return Object
+ */
+ public Object getInfluxMeasurement() {
+ return measurement;
+ }
+
+ public static void check(Object measurement) {
+ if
(!measurement.getClass().isAnnotationPresent(com.influxdb.annotations.Measurement.class))
{
+ throw new IllegalArgumentException(
+ "There is no " +
com.influxdb.annotations.Measurement.class.getCanonicalName() + " annotation
for "
+ + measurement + "[" +
measurement.getClass() + "]");
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Measurement{" +
+ "measurement=" + measurement +
+ '}';
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Measurements.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Measurements.java
new file mode 100644
index 00000000000..c774672d3ec
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Measurements.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * List of influxdb2 Measurement
+ * <p>
+ * {@link Measurement}.
+ */
+public final class Measurements {
+ private List<Measurement> measurements = new ArrayList<>();
+
+ private Measurements() {
+ }
+
+ private Measurements(List<Measurement> measurements) {
+ this.measurements = measurements;
+ }
+
+ public static Measurements create() {
+ return new Measurements();
+ }
+
+ public static Measurements create(List<Measurement> measurements) {
+ return new Measurements(measurements);
+ }
+
+ public static Measurements create(Measurement measurement) {
+ return new Measurements().addMeasurement(measurement);
+ }
+
+ public static Measurements create(Object measurement) {
+ return create(Measurement.fromObject(measurement));
+ }
+
+ /**
+ * get influxdb2 write measurements
+ *
+ * @return List<Measurement>
+ */
+ public List<Object> getInfluxMeasurements() {
+ return
measurements.stream().map(Measurement::getInfluxMeasurement).collect(Collectors.toList());
+ }
+
+ public Measurements setMeasurements(List<Measurement> measurements) {
+ this.measurements = measurements;
+ return this;
+ }
+
+ public Measurements addMeasurement(Measurement measurement) {
+ this.measurements.add(measurement);
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "Measurements{" + "measurements=" + measurements + '}';
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Points.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Points.java
new file mode 100644
index 00000000000..ffd092f3b79
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Points.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.influxdb.client.write.Point;
+
+/**
+ * List of InfluxDb write point
+ * <p>
+ * {@link Point}
+ */
+public final class Points {
+ private List<Point> points = new ArrayList<>();
+
+ private Points() {
+
+ }
+
+ private Points(List<Point> points) {
+ this.points = points;
+ }
+
+ public static Points create() {
+ return new Points();
+ }
+
+ public static Points create(List<Point> points) {
+ return new Points(points);
+ }
+
+ public Points addPoint(Point point) {
+ this.points.add(point);
+ return this;
+ }
+
+ public Points setPoints(List<Point> points) {
+ this.points = points;
+ return this;
+ }
+
+ /**
+ * get influxdb2 write points
+ *
+ * @return ist<Point>
+ */
+ public List<Point> getInfluxPoints() {
+ return points;
+ }
+
+ @Override
+ public String toString() {
+ return "Points{" +
+ "points=" + points +
+ '}';
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Record.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Record.java
new file mode 100644
index 00000000000..89ef913655f
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Record.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.influxdb2.data;
+
+/**
+ * Influxdb write Record
+ */
+public class Record {
+ private String record;
+
+ public Record(String record) {
+ this.record = record;
+ }
+
+ public static Record fromString(String record) {
+ return new Record(record);
+ }
+
+ public String getInfluxRecord() {
+ return record;
+ }
+
+ public void setRecord(String record) {
+ this.record = record;
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Records.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Records.java
new file mode 100644
index 00000000000..8f4ffb2380b
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/data/Records.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.influxdb2.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * InfluxDb write records
+ * <p>
+ * {@link Record}
+ */
+public class Records {
+ private List<Record> records = new ArrayList<>();
+
+ public Records() {
+ }
+
+ private Records(List<Record> records) {
+ this.records = records;
+ }
+
+ /**
+ * get influxdb2 write records
+ *
+ * @return List<String>
+ */
+ public List<String> getInfluxRecords() {
+ return
this.records.stream().map(Record::getInfluxRecord).collect(Collectors.toList());
+ }
+
+ public void setRecords(List<Record> records) {
+ this.records = records;
+ }
+
+ public static Records create(List<Record> records) {
+ return new Records(records);
+ }
+
+ public static Records create(Record record) {
+ return new Records().addRecord(record);
+ }
+
+ public static Records create(String record) {
+ return create(Record.fromString(record));
+ }
+
+ public Records addRecord(String record) {
+ this.records.add(Record.fromString(record));
+ return this;
+ }
+
+ public Records addRecord(Record record) {
+ this.records.add(record);
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "Records{" + "records=" + records + '}';
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/enums/Operation.java
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/enums/Operation.java
new file mode 100644
index 00000000000..c2f02443355
--- /dev/null
+++
b/components/camel-influxdb2/src/main/java/org/apache/camel/component/influxdb2/enums/Operation.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2.enums;
+
+/**
+ * InfluxDb Operation
+ */
+public enum Operation {
+ INSERT("INSERT"),
+ PING("PING"),
+ ;
+
+ private final String operation;
+
+ Operation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ @Override
+ public String toString() {
+ return operation;
+ }
+}
diff --git
a/components/camel-influxdb2/src/main/resources/META-INF/services/org/apache/camel/component/influxdb2
b/components/camel-influxdb2/src/main/resources/META-INF/services/org/apache/camel/component/influxdb2
new file mode 100644
index 00000000000..fbafbf7e354
--- /dev/null
+++
b/components/camel-influxdb2/src/main/resources/META-INF/services/org/apache/camel/component/influxdb2
@@ -0,0 +1 @@
+class=org.apache.camel.component.influxdb2.InfluxDb2Component
diff --git
a/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/AbstractInfluxDbTest.java
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/AbstractInfluxDbTest.java
new file mode 100644
index 00000000000..ff30d41e69b
--- /dev/null
+++
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/AbstractInfluxDbTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+import com.influxdb.client.InfluxDBClient;
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.junit5.CamelTestSupport;
+
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+
+public abstract class AbstractInfluxDbTest extends CamelTestSupport {
+
+ InfluxDBClient mockedDbConnection = mock(InfluxDBClient.class,
RETURNS_DEEP_STUBS);
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ CamelContext context = super.createCamelContext();
+ context.getRegistry().bind("influxDbBean", mockedDbConnection);
+
context.getPropertiesComponent().setLocation("classpath:influxdb2.test.properties");
+ return context;
+ }
+
+}
diff --git
a/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/InfluxDb2ProducerPingTest.java
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/InfluxDb2ProducerPingTest.java
new file mode 100644
index 00000000000..5495bdfc22a
--- /dev/null
+++
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/InfluxDb2ProducerPingTest.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class InfluxDb2ProducerPingTest extends AbstractInfluxDbTest {
+
+ @EndpointInject("mock:test")
+ MockEndpoint successEndpoint;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ //test route
+ from("direct:test")
+
.to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}&operation=ping")
+ .to("mock:test");
+ }
+ };
+ }
+
+ @BeforeEach
+ public void resetEndpoints() {
+ successEndpoint.reset();
+ }
+
+ @Test
+ public void ping() throws InterruptedException {
+
+ successEndpoint.expectedMessageCount(1);
+
+ sendBody("direct:test", "test");
+
+ successEndpoint.assertIsSatisfied();
+ }
+
+}
diff --git
a/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/InfluxDb2ProducerTest.java
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/InfluxDb2ProducerTest.java
new file mode 100644
index 00000000000..2bab7e2ffc9
--- /dev/null
+++
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/InfluxDb2ProducerTest.java
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.influxdb2;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.influxdb.annotations.Column;
+import com.influxdb.client.write.Point;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.influxdb2.data.Measurement;
+import org.apache.camel.component.influxdb2.data.Measurements;
+import org.apache.camel.component.influxdb2.data.Points;
+import org.apache.camel.component.influxdb2.data.Record;
+import org.apache.camel.component.influxdb2.data.Records;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class InfluxDb2ProducerTest extends AbstractInfluxDbTest {
+
+ @EndpointInject("mock:test")
+ MockEndpoint successEndpoint;
+
+ @EndpointInject("mock:error")
+ MockEndpoint errorEndpoint;
+
+ @BeforeEach
+ public void resetEndpoints() {
+ errorEndpoint.reset();
+ successEndpoint.reset();
+ }
+
+ @com.influxdb.annotations.Measurement(name = "temperature")
+ private static class Temperature {
+
+ @Column(tag = true)
+ String location;
+
+ @Column
+ Double value;
+
+ @Column(timestamp = true)
+ Instant time;
+ }
+
+ @Test
+ public void writePoint() throws Exception {
+
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+
+ Point point = Point.measurement("temperature");
+
+ sendBody("direct:test", point);
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+
+ }
+
+ @Test
+ public void writePointFromMap() throws Exception {
+
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+
+ Map<String, Object> pointMap = createMapPoint();
+ sendBody("direct:test", pointMap);
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+
+ }
+
+ @Test
+ public void writeRecord() throws Exception {
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ Record record = Record.fromString("temperature,location=north
value=60.0");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+
+ sendBody("direct:test", record);
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+ }
+
+ @Test
+ public void writeMeasurement() throws Exception {
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+
+ Temperature temperature = new Temperature();
+ temperature.value = 50.0d;
+ temperature.time = Instant.now();
+ temperature.location = "xxx";
+
+ Measurement measurement = Measurement.fromObject(temperature);
+
+ sendBody("direct:test", measurement);
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+ }
+
+ @Test
+ public void writePoints() throws Exception {
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+ ArrayList<Point> points = new ArrayList<>() {
+ {
+ add(Point.measurement("temperature"));
+ }
+ };
+
+ sendBody("direct:test", Points.create(points));
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+ }
+
+ @Test
+ public void writeRecords() throws Exception {
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+
+ sendBody("direct:test", Records.create("temperature,location=north
value=60.0"));
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+ }
+
+ @Test
+ public void writeMeasurements() throws Exception {
+ errorEndpoint.expectedMessageCount(0);
+ successEndpoint.expectedMessageCount(1);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+ Temperature temperature = new Temperature();
+ temperature.value = 50.0d;
+ temperature.time = Instant.now();
+ temperature.location = "xxx";
+
+ Measurement measurement = Measurement.fromObject(temperature);
+
+ Measurements.create(measurement);
+ sendBody("direct:test", Records.create("temperature,location=north
value=60.0"));
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+ }
+
+ @Test
+ public void missingMeasurementNameFails() throws Exception {
+
+ errorEndpoint.expectedMessageCount(1);
+ successEndpoint.expectedMessageCount(0);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
errorHandler(deadLetterChannel("mock:error").redeliveryDelay(0).maximumRedeliveries(0));
+
from("direct:test").to("influxdb2:influxDbBean?org={{influxdb2.testOrg}}&bucket={{influxdb2.testBucket}}")
+ .to("mock:test");
+ }
+ });
+
+ Map<String, Object> pointMap = createMapPoint();
+ pointMap.remove(InfluxDb2Constants.MEASUREMENT);
+ sendBody("direct:test", pointMap);
+
+ errorEndpoint.assertIsSatisfied();
+ successEndpoint.assertIsSatisfied();
+
+ }
+
+ private Map<String, Object> createMapPoint() {
+ Map<String, Object> pointMap = new HashMap<>();
+ pointMap.put(InfluxDb2Constants.ORG, "MyTestOrg");
+ pointMap.put(InfluxDb2Constants.BUCKET, "MyTestBucket");
+ pointMap.put(InfluxDb2Constants.MEASUREMENT, "MyTestMeasurement");
+ pointMap.put("CPU", 1);
+ return pointMap;
+ }
+
+}
diff --git
a/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDbConverterTest.java
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDbConverterTest.java
new file mode 100644
index 00000000000..379e8276d8f
--- /dev/null
+++
b/components/camel-influxdb2/src/test/java/org/apache/camel/component/influxdb2/converters/CamelInfluxDbConverterTest.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.influxdb2.converters;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.influxdb.client.write.Point;
+import org.apache.camel.component.influxdb2.InfluxDb2Constants;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class CamelInfluxDbConverterTest {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(CamelInfluxDbConverterTest.class);
+
+ @Test
+ public void doesNotAddCamelHeaders() {
+ Map<String, Object> pointInMapFormat = new HashMap<>();
+ pointInMapFormat.put(InfluxDb2Constants.MEASUREMENT, "testCPU");
+ double value = 99.999999d;
+ pointInMapFormat.put("busy", value);
+
+ Point p = CamelInfluxDb2Converters.fromMapToPoint(pointInMapFormat);
+ assertNotNull(p);
+
+ String line = p.toLineProtocol();
+
+ assertNotNull(line);
+ LOG.debug("doesNotAddCamelHeaders generated: \"{}\"", line);
+ assertTrue(!line.contains(InfluxDb2Constants.MEASUREMENT));
+
+ }
+
+ @Test
+ public void canAddDouble() {
+ Map<String, Object> pointInMapFormat = new HashMap<>();
+ pointInMapFormat.put(InfluxDb2Constants.MEASUREMENT, "testCPU");
+ double value = 99.999999d;
+ pointInMapFormat.put("busy", value);
+
+ Point p = CamelInfluxDb2Converters.fromMapToPoint(pointInMapFormat);
+ assertNotNull(p);
+
+ String line = p.toLineProtocol();
+
+ assertNotNull(line);
+ LOG.debug("Doublecommand generated: \"{}\"", line);
+ assertTrue(line.contains("busy=99.999999"));
+
+ }
+
+ @Test
+ public void canAddInt() {
+ Map<String, Object> pointInMapFormat = new HashMap<>();
+ pointInMapFormat.put(InfluxDb2Constants.MEASUREMENT, "testCPU");
+ int value = 99999999;
+ pointInMapFormat.put("busy", value);
+
+ Point p = CamelInfluxDb2Converters.fromMapToPoint(pointInMapFormat);
+ assertNotNull(p);
+
+ String line = p.toLineProtocol();
+
+ assertNotNull(line);
+ LOG.debug("Int command generated: \"{}\"", line);
+ assertTrue(line.contains("busy=99999999"));
+
+ }
+
+ @Test
+ public void canAddByte() {
+ Map<String, Object> pointInMapFormat = new HashMap<>();
+ pointInMapFormat.put(InfluxDb2Constants.MEASUREMENT, "testCPU");
+ byte value = Byte.MAX_VALUE;
+ pointInMapFormat.put("busy", value);
+
+ Point p = CamelInfluxDb2Converters.fromMapToPoint(pointInMapFormat);
+ assertNotNull(p);
+
+ String line = p.toLineProtocol();
+
+ assertNotNull(line);
+ LOG.debug("Byte command generated: \"{}\"", line);
+ assertTrue(line.contains("busy=127"));
+
+ }
+}
diff --git
a/components/camel-influxdb2/src/test/resources/influxdb2.test.properties
b/components/camel-influxdb2/src/test/resources/influxdb2.test.properties
new file mode 100644
index 00000000000..b90616fb218
--- /dev/null
+++ b/components/camel-influxdb2/src/test/resources/influxdb2.test.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+influxdb2.testOrg=myTestOrg
+influxdb2.testBucket=myTestBucket
+influxdb2.testToken=myTestToken
+
diff --git a/components/camel-influxdb2/src/test/resources/log4j2.properties
b/components/camel-influxdb2/src/test/resources/log4j2.properties
new file mode 100644
index 00000000000..c98f0875aa6
--- /dev/null
+++ b/components/camel-influxdb2/src/test/resources/log4j2.properties
@@ -0,0 +1,27 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+appender.file.type=File
+appender.file.name=file
+appender.file.fileName=target/camel-influxdb2-test.log
+appender.file.layout.type=PatternLayout
+appender.file.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type=Console
+appender.out.name=out
+appender.out.layout.type=PatternLayout
+appender.out.layout.pattern=[%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level=INFO
+rootLogger.appenderRef.file.ref=file
\ No newline at end of file
diff --git a/components/pom.xml b/components/pom.xml
index 64e418a687e..3bbe9690c1b 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -171,6 +171,7 @@
<module>camel-ignite</module>
<module>camel-infinispan</module>
<module>camel-influxdb</module>
+ <module>camel-influxdb2</module>
<module>camel-iota</module>
<module>camel-irc</module>
<module>camel-ironmq</module>
diff --git a/parent/pom.xml b/parent/pom.xml
index 4dd88ecf680..b5215285b45 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -247,6 +247,7 @@
<impsort-maven-plugin-version>1.6.0</impsort-maven-plugin-version>
<infinispan-version>14.0.3.Final</infinispan-version>
<influx-java-driver-version>2.22</influx-java-driver-version>
+
<influx-client-java-driver-version>6.7.0</influx-client-java-driver-version>
<influx-guava-version>20.0</influx-guava-version>
<irclib-version>1.10</irclib-version>
<ironmq-version>3.0.5</ironmq-version>
@@ -1596,6 +1597,11 @@
<artifactId>camel-influxdb</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-influxdb2</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-iota</artifactId>