Search code examples
javaapache-camelinfluxdb

How to define an Apache Camel route to InfluxDB


I want to send data to an InfluxDB using Apache Camel. I am at such a beginner's level, that I cannot even understand camel's documentation. I am struggling what exactly needs to be written in the <route> tag of the spring configuration XML. In the documentation it says:

  • URI format: influxdb://beanName?[options]
  • The InfluxDB endpoint is configured using URI syntax: influxdb:connectionBean

How do I use this information? Could you provide me a more instructive example of how the config.xml looks like and how this is called in code?

Thanks


Solution

  • I think you need to configure a spring boot InfluxDb class instance and then reference it as stated in the documentation using beanName.

    This can be created using spring boot auto configuration:

    According to Spring AnnotationNameGenerator the name of the default (from the yml auto configured bean) should simply be influxDB. We can also look at the bean definition code and confirm it is creating an InfluxDB class instance.

    So then configure influxdb://influxDB in camel.


    Besides auto configuring this alternative should work too (untested - source):

    @Configuration
    public class AppConfig {
        @Bean(name = "myInflux")
        public InfluxDb influxClient{
            return InfluxDBFactory.connect(databaseURL, userName, password);
        }
    }
    

    And then configure influxdb://myInflux in camel.