How to send device events in realtime to clustered 3rd party app

What product/components do you use and which version/fix level are you on?

Cumulocity IoT incl. Notifications 2.0 on version 10.11

Is your question related to the free trial, or to a production (customer) instance?

Production instance

What are you trying to achieve? Please describe it in detail.

I have the following situation:
Devices will occasionally need to request something from a server. This requests needs to be handled by a 3rd party application. The idea of the setup was to let the devices send a C8Y event and on the 3rd party application side develop a connection to Notifications 2.0.
The 3rd party application is also in an HA setup and has multiple nodes. Every node should be able to handle events from every device.
From the documentation however it seems events cannot be subscribed tenant wide on Notifications 2.0. Only alarms and managed objects. The device number is expected to grow pretty high, therefore subscribing to every device in mo context would be a lot of calls.

What is the recommended way to implement such an architecture?

I’d recommend to eliminate notifications from the solution entirely.

I’d create a simple microservice where the devices send the information. The microservice then creates an event (or whatever fits best) in C8Y for bookkeeping and also forwards the required information to the third party application.

This architecture can be scaled much more easily and more dedicated to the purpose with increasing load than a shared notification service. There is even an option to autoscale microservices.

In my view it’s a typical messaging vs HTTP/WebHook issue.

You can implement that by exposing REST endpoints with a load balancer on the 3rd party applications but still the implementation and communication is tightly bound to each other. So changing anything in the communication, everything (microservice, 3rd party application etc.) must be touched because you have somehow a chain of communication: Device → microservice → 3rd party application and vice versa when asynchronously.
Sure you can scale that by using a load balancer and auto-scaling microservices but the microservice might be always a single point of failure. When not available it is really hard to recover and get the request forwarded to the 3rd party application as they occurred (No message queue, risk of race conditions etc.).

Using a messaging scaling concept is loosely coupled. You just define publisher and can add as many subscriber you want to without the need to touch a microservice. Device → Message Bus, 3rd party application → Message Bus. Messages are queued and you can avoid race conditions by processing the messages in the order they were sent. That’s the theoretical part :smiley:
Unfortunately Notifications 2.0 is not a “real” message bus (by design) so those concepts are not fully supported.

What can be done:
You can create a “shared” token for all the consumers and make sure the consumers have a different id in 10.16. Introducing Some Cumulocity IoT Notification 2.0 Enhancements
Still for each device you have to add a subscription but you just use one web socket connection for each instance on the 3rd party application as the ws-connection can handle multiple subscriptions for multiple devices/context at the same time.

In an ideal world you would just subscribe on an event of a specific type in tenant scope but this is currently not supported. Good news is: There is already a feature request and it seems to be prioritized in future releases as this was also requests by the c8y integration team.