如何定义到 InfluxDB 的 Apache Camel 路由

How to define an Apache Camel route to InfluxDB

我想使用 Apache Camel 将数据发送到 InfluxDB。我处于初学者的水平,我什至无法理解骆驼的文档。我正在努力在 spring 配置 XML 的 <route> 标记中到底需要写什么。 In the documentation 它说:

我如何使用这些信息?您能否提供一个更有启发性的示例,说明 config.xml 的外观以及如何在代码中调用它?

谢谢

我认为您需要配置一个 spring 启动 InfluxDb class 实例,然后使用 按照文档中的说明引用它beanName.

这可以使用 spring 引导自动配置创建:

根据 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 并确认它正在创建一个 InfluxDB class 实例。

那么在camel中配置influxdb://influxDB


除了自动配置之外,此替代方案也应该有效(未经测试 - source):

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

然后在camel中配置influxdb://myInflux