Sharing transaction between processes MySQL

Viewed 59

I have a python script that runs a data migration script through a transaction interfacing with a MySQL DB. I am the process of moving this script over to NodeJS which is accessible through an API endpoint.

The problem I am having is that, since my Python data migration is wrapped in a transaction, then my Node process cannot interact with the new data.

I have started to collect relevant information in my Python script and then send in over the POST body to my Node script for now, but this strategy has it's own complications with keep data in sync and then responding with the new information that I need to make sure to insert back in my Python process.

Is there a better way that I can share the transaction data between my Python and my Node process?

Thank you

1 Answers

Here are some ideas:

  • Store data in a cache server that both the Python app and the Node.js app have access to. Popular software for this is Memcached or Redis.

  • Use a message queue to send data back and forth between the apps. Some examples are RabbitMQ or ActiveMQ.

  • Commit the data in the database using your Python app. Then make an http POST request to the Node.js app, to signal the Node.js app the data is ready (the POST request doesn't need to contain the data). The Node.js app does what it's going to do with the data before sending the http response. So the Python app knows that once it receives the response, the data has been updated by Node.js.

Related