【问题标题】:AWS IoT MQTT Client with Apache camel-mqtt带有 Apache camel-mqtt 的 AWS IoT MQTT 客户端
【发布时间】:2018-01-11 17:35:21
【问题描述】:

我正在考虑使用 Apache Camel(使用 camel-mqtt)+ Spring Boot 构建 AWS IoT Java 客户端。这听起来很适合我,但找不到任何例子。有什么我看不到的缺点吗?有兴趣看到任何指针。

【问题讨论】:

  • 您也可以考虑使用 camel-paho,因为 Eclipse Paho 比 camel-mqtt 使用的 MQTT 客户端维护得更多。例如,您可以查看 IoT 博客。有些人已经展示了如何使用 Camel、MQTT 和 IoT 设备做到这一点。
  • 感谢@ClausIbsen! ,你知道任何用于连接 AWS IoT 的好例子 camel-paho 吗?我似乎找不到任何可靠的例子。

标签: spring-boot apache-camel mqtt aws-iot spring-integration-mqtt


【解决方案1】:

我得到它使用以下配置。 sslContext bean 持有证书/安全性:

    @Bean
    RouteBuilder awsIoTRoute() {

        return new RouteBuilder() {

            @Override
            public void configure() throws Exception {

                from("timer://foo?repeatCount=0&delay=5000&fixedRate=true&period=17s")
                    .setBody(simple("TEST MESSAGE"))
                    .to("mqtt:awsIoTPublisher?host=ssl://{{aws.iot.host}}:8883&publishTopicName={{aws.iot.pub.topic}}&clientId={{aws.iot.pub.clientId}}&sslContext=#sslContext")
                    .log("Sent :"+body().convertToString().toString());

                from("mqtt:awsIoTReciever?host=ssl://{{aws.iot.host}}:8883&subscribeTopicName={{aws.iot.sub.topic}}&clientId={{aws.iot.sub.clientId}}&sslContext=#sslContext").log("Recieved : "+body().convertToString());


            }
        };
    }

【讨论】:

  • 如何配置 sslContext?