简体   繁体   English

订阅Java后端中的AWS IoT主题

[英]Subscribing to an AWS IoT topic in a Java backend

When using the AWS Java SDK ( aws-java-sdk-iot ) it is possible to publish messages to an AWS IoT topic from a backend system, but it doesn't seem possible to subscribe to a topic? 使用AWS Java SDKaws-java-sdk-iot )时,可以从后端系统将消息发布到AWS IoT主题,但似乎无法订阅该主题? What is the reasoning behind this? 这背后的原因是什么?

We are looking for a way to have our Java backend (deployed on AWS) take part in our IoT solution and being able to publish and subscribe to topics. 我们正在寻找一种方法来让我们的Java后端(在AWS上部署)参与我们的Io​​T解决方案,并能够发布和订阅主题。 If using the sdk is not the way to go, what would be a good design to achieve this? 如果没有使用sdk的方法,那么实现此目的的最佳设计是什么?

We do not want to use the AWS Device SDK for this. 我们不想为此使用AWS Device SDK。

The non-device SDKs for IoT are request/response oriented and use the HTTP protocol. 物联网的非设备SDK面向请求/响应,并使用HTTP协议。 It would be a weird API (see the SQS API) if it held open an HTTP request until a message arrived on a subscription. 如果它一直打开HTTP请求,直到消息到达订阅,这将是一个怪异的API(请参阅SQS API)。

The AWS Device SDK is not a bad choice, but you could avoid using it by doing the same thing it does and set up a persistent connection to the broker using MQTT or MQTT + WebSocket. AWS Device SDK并不是一个不错的选择,但是您可以通过做相同的事情来避免使用它,并使用MQTT或MQTT + WebSocket设置与代理的持久连接。

If you decide to roll your own MQTT client, using Netty and its MQTT codec would be a reasonable place to start. 如果您决定推出自己的MQTT客户端,那么使用Netty及其MQTT编解码器将是一个不错的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM