<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                使用Lua腳本可以實現更復雜的數據處理邏輯,go-mysql-transfer支持Lua5.1語法 # **示例** t_user表,數據如下: ![](https://img.kancloud.cn/b7/ae/b7aea55df3a0d071d67a930b1f497314_589x141.png) ## **示例一** Lua腳本: ``` local json = require("json") -- 加載json模塊 local ops = require("mqOps") --加載mq操作模塊 local row = ops.rawRow() --當前數據庫的一行數據,table類型,key為列名稱 local action = ops.rawAction() --當前數據庫事件,包括:insert、updare、delete local id = row["ID"] --獲取ID列的值 local userName = row["USER_NAME"] --獲取USER_NAME列的值 local password = row["PASSWORD"] --獲取USER_NAME列的值 local createTime = row["CREATE_TIME"] --獲取CREATE_TIME列的值 local result = {} -- 定義一個table,作為結果 result["id"] = id result["action"] = action if action == "delete" -- 刪除事件 then local val = json.encode(result) -- 將result轉為json ops.SEND("user_topic",val) -- 發送消息,第一個參數為topic(string類型),第二個參數為消息內容 else result["userName"] = userName result["password"] = password result["createTime"] = createTime result["source"] = "binlog" -- 數據來源 local val = json.encode(result) -- 將result轉為json ops.SEND("user_topic",val) -- 發送消息,第一個參數為topic(string類型),第二個參數為消息內容 end ``` 引入Lua腳本: ``` rule: - schema: eseap #數據庫名稱 table: t_user #表名稱 lua_file_path: lua/t_user_rabbit.lua #lua腳本文件 ``` insert事件,同步到RabbitMQ的數據如下: ![](https://img.kancloud.cn/54/90/5490a4dd72561657e4cf5895f5fd8fa5_367x266.jpg) update事件,同步到RabbitMQ的數據如下: ![](https://img.kancloud.cn/48/1f/481f5366ae4eea3d7ffa6cc95bf9eba8_356x263.jpg) delete事件,同步到RabbitMQ的數據如下: ![](https://img.kancloud.cn/2c/2b/2c2b1e9bd33c0d53b0f6901c2745ec54_339x156.jpg) ## **示例二** 使用如下腳本: ``` local ops = require("mqOps") --加載mq操作模塊 local row = ops.rawRow() --當前數據庫的一行數據,table類型,key為列名稱 local action = ops.rawAction() --當前數據庫事件,包括:insert、updare、delete local userName = row["USER_NAME"] --獲取USER_NAME列的值 if action == "insert" then -- 只監聽添加事件 local str = string.format("恭喜您:%s 注冊成功",userName) ops.SEND("user_topic",str) -- 發送消息,第一個參數為topic(string類型),第二個參數為消息內容 end ``` 同步到RabbitMQ的數據如下: ![](https://img.kancloud.cn/2c/cb/2ccb2e607020bc0bb0385b5a9ee6f188_369x95.jpg) # **mqOps模塊** 提供的方法如下: 1. SEND: 發送操作,如:ops.SEND(topic,result)。參數topic為字符串類型;參數result為要發送的消息
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看