I want to code as a personnal project (i’m student) a bridge between two cms located in 2 differents servers and databases.
For example an e-commerce cms and an ERP : I want to synchronise only let’s say the ‘order’ table.
But the table schema is not the same so I have to make a ‘compatibility’ script to update the right corresponding fields.
Let’s say it’s done and I can synchronise the 2 tables in both directions : I can add an order in the e-commerce table when a new order is written in the ERP table. And the same in the other direction.
But I need to execute my scripts to make this happen.
I can put the script in a cron job so it’s executed at 18 pm, but I want the data to be synchronised in real time.
Which means when a new order is added in the ERP table, the e-commerce table on the other server is updated too. And the same thing in the other direction.
The only solution I found is to fire some events. When the ERP table is updated a script is launched and update the e-commerce table. When the e-commerce cms table is updated, a script is launched and update the ERP table.
But it needs two scripts : one in both sides… I want only a script in one of the side.
How can I achieve this ? Is there a way/ a process to sync them in real time, just by creating an application in one of both sides
Use the same database for the two CMS instances.
If you’re not doing that (or using a semi-real-time database replication layer), then the only way to keep them in sync with low latency is event-based message passing like you describe in your post.
This does not have a zero latency – you don’t have a transactional commit system, so there is a moment after one CMS does something and before the other sees it. Whether this will cause you issues depends on what your particular use case is.
Again, the right way to do this is to have two frontends sharing one backend.