Question

Our customer is running a Single Master with multiple slaves(in a cluster).

Now, he wants us to write some triggers (only) that run on the slave(s) when new records are added, updated or deleted on the slave(s). This trigger should run an external java program.

Is this possible ? recommended ?

How do we run a java program from the trigger ? Is it recommended/safe ?

Any gotchas that need to be taken care of ?

No correct solution

OTHER TIPS

Yes, it's possible. You need to create those triggers on slaves, they'll be triggered as binlog is read and executed.

You can execute an external program using sys_exec UDF available from MySQL Forge (or this link).

SELECT sys_exec('/path/to/program')

Just beware of what the program does, until the external program returns - query won't finish. If it's something that does further processing, I suggest creating some sort of a queueing system listening on a port so you can immediately exit(0), let the program do its stuff and release mysql thread so the query can finish.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top