Realtime notifications of node changes

(Leeland Clay) #1

Hello,
I'm working on a dating app. I just setup the "Like" relationships and I'm trying to work out a way to notify the other user that someone like them (if they're logged in). I looked at the APOC triggers, but they seem to be more of "call a web api, and manipulate data" type of triggers instead of a realtime subscriber type notification.
I know I could just setup a timed polling that would go out and check at a preset timespan...but I really dislike that idea (for SO many reasons).
I found several articles and postings that were basically saying that it wasn't available...however all of them were older. Has subscription services been added in recently?
Thanks,
Leeland

0 Likes

(M. David Allen) #2

If you want real-time notification of node changes, this is exactly what APOC triggers are for. Whenever a new node is created, you can run arbitrary cypher.

Next comes the question of who the subscribers are. Neo4j does not itself implement any kind of pub/sub arrangement, and it's unlikely that it would because this is a separate concern that's better addressed by a different system. This is what things like neo4j-streams are for:

The idea is that whenever new nodes are created, you configure neo4j-streams to publish a message on a kafka topic. Your subscribers then subscribe to that kafka topic, not to neo4j. Kafka is a system that is purpose built for such pub/sub design patterns, so I'd recommend using something like that for this purpose.

0 Likes

(Leeland Clay) #3

I like that concept. I don't have the bandwidth to research it properly right now...but I've added it to my list of study links. Thanks!!!!!

1 Like