I need a pub/sub library for Node.js that the publisher (the server side) is able to start publishing on a topic upon a subscriber listens to that topic and stop publishing when all topic listeners are unsubscribed/offline.
Use case: On server side, I need to poll some hardware sensors and publish their data on topics. Since keeping the sensors powered on and reading them is costly, so I don't want to blindly keep the sensors powered on and polling their data when there is no subscriber.
I studied MQTT/Socket.io/Kafka/... None of them supports the "lazy" publishing feature.
Requirements:
- Authentication and access control for subscribers.
- The only publisher (i.e. the server side that access to the sensors) must be able to be informed two events for each topic: 1.Someone subscribed (this event for start reading the sensor). 2. All unsubscribed/offline (this event for stop reading the sensor).