我有一个 nodejs 应用程序,我在其中使用 MySQL 事件侦听实时数据库更改,并且由于某种原因它停止读取日志并获取更改...我使用套接字 io 来传达实时更改。
const watcher = async () => {
var instance = new MySQLEvents(connection, {
startAtEnd: true,
serverId: 1,
})
await instance.start() .then(() => log4j.loggerinfo.info(`i'm running`))
.catch(err => log4j.loggerinfo.error(`${err.message}`))
instance.addTrigger({
name: 'balance update',
expression: 'afff.users.balance',
statement: MySQLEvents.STATEMENTS.UPDATES,
onEvent: async(event) => { // You will receive the events here
instance.pause()
await doSomethingOnBalanceChange(event)
instance.resume()
// io.of('/').emit('operationReceived', event)
},
})