- Newest
- Most votes
- Most comments
You can use Rules Engine to do the 'services' topic subscriptions for you (create a Topic Rule that subscribe to 'services/ms1' and another rule for 'services/ms2'; or one rule that subscribes to 'services/+'). When a message is published to services/ms1 or services/ms2 then only the subscribed Rule(s) will fire (versus all subscribed micro-services).
The rule can be used to perform a Lambda Action or HTTP Action. If your services have an HTTPS endpoint, then HTTP Action would be my preference to get over the Lambda concurrency limitation. For more information on HTTP Action see https://aws.amazon.com/blogs/iot/route-data-directly-from-iot-core-to-your-web-services/
To make sure only 1 micro-service fires to handle the request, you could use a load balancer (https://aws.amazon.com/elasticloadbalancing/) or target specific instance from the Rule.
Hi yarch,
I recommend checking out the Well-Architected IoT Lens whitepaper: https://d1.awsstatic.com/whitepapers/architecture/AWS-IoT-Lens.pdf This might answer some of your current and future questions with some guidance on how to think about architecting IoT solutions on AWS.
In addition to Artem's advice, I would recommend decoupling your devices from the microservices by using message queues. For example, devices report their state or make a query to a topic oriented around itself (like devices/d1/reported or devices/d1/query) and then using the rules engine to contextualize which message queues a given message should be added to. SQS is a great tool for designing application workloads where requests are processed by a single worker. Your microservice worker would then read messages off the queue, execute logic, then send a message back to IoT Core. It is more acceptable for the microservice to know about topic architecture and could publish to a topic like devices/d1/response. This kind of design simplifies your devices (they just know about themselves), makes your architecture more agile (cloud structure can evolve without needing an update on the device), and achieves the singular processing of device messages in your microservice architecture.
Hope this helps,
Ryan
Relevant content
- asked 4 months ago
- Accepted Answerasked 7 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 3 years ago