- Newest
- Most votes
- Most comments
Yes in this pseudocode example, you would access latitude with
message.lat
inside the anonymous function.
Hi SteveB,
The integration between IoT Analytics pipeline and Lambda supports batching of messages. The default batch size is 1 when using the IoT Analytics console. This is why you see a list of one message instead of the same message forwarded by IoT Core.
To work with batched messages sent by IoT Analytics, you need to iterate through the received event array. An example:
let messagesReturnedToIoTAnalytics = [];
event.forEach(message => {
// do some stuff to `message`
// ...code...
// then add to returned list
messagesReturnedToIoTAnalytics.push(message);
});
return messagesReturnedToIoTAnalytics;
Hope this helps,
Ryan
Hi Ryan,
It definitely does help. I was going to look at the Python example from the user guy and try to work backwards so this helps. I will work on this today and Ill leave this open in case I get stumped again in the next couple of days, but this definitely helps. thanks!
Hi Ryan,
It definitely does help. I was going to look at the Python google maps example from the user guide and try to work backwards so this helps. I will work on this today and I'll leave this open in case I get stumped again in the next couple of days, but this definitely helps.
which art of your pseudo code relates to the incoming ''event.member', in my case (event.lat)
is it message.lat' ? since your not defining 'message' I'm assuming this is really the incoming event object?
thanks
Edited by: SteveB123 on Nov 25, 2019 9:02 AM
RyanB you are a genius, you have solved my problem after i've spend more then 6 hours on i,t to no avail. I would have had to work back from the Python example to even get a clue thatwe had to parse batched messages to extract the event objects members.
Do you know where is this documented? I'm looking through the IoT Analytics documentation and I don't see this issue listed anywhere. I'm wondering what AWS documentation explains this issue on another AWS service? Thanks again
Steve
I will pass this feedback on to the service team. This behavior is documented in the IoT Analytics user guide, under the Lambda pipeline activity: https://docs.aws.amazon.com/iotanalytics/latest/userguide/pipeline-activities.html#aws-iot-analytics-pipeline-activities-lambda
The code
for e in event:
shows in Python that an iterator is needed to act on individual messages. We'll see about making it more clear that this is required even for a batch of one message.
Ryan
Relevant content
- asked 2 years ago
- Accepted Answer
- asked 5 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago