Search code examples
databaseneo4jmicroservices

Neo4j subscribe to DB changes in Python


There are 2 microservices, one inserts data into the database using a queue of entries and the other one makes some complicated calculations and creates relations between nodes based on this calculation.

Instead of calling the second microservice in the first one using a REST API, websocket etc., I want to just subscribe to db changes in the second microservice. Is there a plugin, library etc. to subscribe neo4j db changes in Python?


Solution

  • Neo4j Streams features Change Data Capture feature that streams db changes to Kafka. https://neo4j.com/labs/kafka/4.0/producer/. If you don't want to use Kafka, you have the option to use APOC triggers, but they are not as mature as kafka IMO. https://neo4j.com/labs/apoc/4.1/background-operations/triggers/. However, you have the option to be very specific which changes do you want to listen for. Here's one example that does a request upon a trigger, but you would probably send a POST request somewhere: https://tbgraph.wordpress.com/2017/03/07/neo4j-apoc-triggers-and-web-apis/