0

Looking to understand whether there is a a bulletproof event from the namagedObject side of c8y where we know the device has just connected.

I have a microservice that listens for events in real time and I want to trigger a process once we know a device has connected to send its payload.

We have used:

"c8y_Connection": {"status":"CONNECTED"}

We have had the microservice log to Slack all events from managedObjects where we saw for three days the "status":"CONNECTED" value in the payload of our demo devices at reporting times.

But after three days, we see no more this "CONNECTED" state (all payloads showing "DISCONNECTED").

What I am trying to achieve from the inventoryObject event is to understand when a device had connected and sent payload to know when data had arrived. I then go get the data and process it externally. This is post registration and as part of the daily data send cycle for my type of device.

What would be the best way to understand when a device has sent payload in a microservice? I want to notify an external application with either “data is arriving for id 35213” or even better, “data has arrived for device 35213, and here’s the $payload”.

TheRealPapa
  • 4,393
  • 8
  • 71
  • 155

1 Answers1

0

Just as a general information ahead: The c8y_Connection fragment showing connected shows an active MQTT connection or an active long polling connection and it is only evaluated once every minute. So if the client is just sending data and immediately disconnecting afterwards this might not picked up.

If you want to see the device having send something to Cumulocity maybe the c8y_Availability fragment is a better as it holds the timestamp when the device last send something.

{ "lastMessage": "2022-10-11T14:49:50.201+09:00", "status": "UNAVAILABLE"}

Also here the evaluation (or better the update to database) only happens every minute.

Both c8y_Availability and c8y_Connection however are only generated if the availability monitoring has been activated for the device (by defining a required interval for the device).

So if you have activated the availability monitoring and you see a "lastMessage" you can reliably say that the device has already send something to Cumulocity.

TyrManuZ
  • 2,039
  • 1
  • 14
  • 23
  • Hey @TyrManuZ!! Thank you so much!! Your insight is really useful. What I am trying to achieve is to know when a device has connected / finished sending payload. I do this in a microservice in c8y instance. How to confirm that the lastMessage date has changed in the current payload? I cannot find an "events history" to check previous to current event. – TheRealPapa Oct 11 '22 at 19:25
  • @TheRealPapa that is very tricky. As you already mentioned there is no log of these updates as it would be simply too much traffic on the large scale. There is a push notification on the notification APIs when this availability fragment is updated but the notification itself does not mention what was updated. So such a push notification could also mean that something else in the device object changed – TyrManuZ Oct 13 '22 at 02:59