I want to write a NodeJS-based application that uses Server Sent Events (SSEs) to listen to events published by Spark Cores. I want the application to record the events it hears in a data store e.g. MySQL or MongoDB. I’d like to use Heroku to host the application and data store.
Has anyone written a similar application? If so I’d really appreciate it if you shared your code and learnings.
harrisonhjones: Tiny thing, maybe fix the mismatched quotations on this line in your example?
console.log("Listening for events’);
Just for clarity. Thanks again.
In the end I decided to go with MySQL as I am more familiar with it than MongoDB. So it was quicker for me to get it up and running. Took me a solid 12 hours work to go from signing up to Heroku to having the stuff detailed below working. Lots of learnings on the way.
For the past week I’ve had my Core publishing events on household temperature every 15, with a NodeJS script running on the Heroku platform listening to those events and recording them in a MySQL database. A website running on Heroku gives summary information on the events.
Only problem I’ve had is my household internet connection which is intermittently flaky. When connectivity is poor, the core can’t connect to the cloud, and so Heroku stops hearing events, and after an hour Heroku goes into sleep mode and does not re-awaken when the core starts publishing events again. Still need to fix this.