<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>

                ## 前言 1. 本章以SpringBlade的blade-ops模塊下的模塊為例進行對接講解 2. 其中order為訂單服務,storage為庫存服務,本章將以這兩個服務講解如何對接到Seata實現分布式事務 3. 打開SpringBlade工程,找到如下項目 ![](https://img.kancloud.cn/05/e2/05e2a086eff1838fcaca193c4a3709d0_774x1636.png) <br> ## 對接準備 1. 需要接入seata的服務pom.xml引入分布式事務依賴 ![](https://img.kancloud.cn/0d/fb/0dfb2150c4fbb542585a7253a8ca2084_1312x1304.png) 2. application-xx.yml加上對應seata的配置 ![](https://img.kancloud.cn/6a/a1/6aa1a1fac9e625444f7b236d4247d86e_994x1176.png) 3. 程序啟動器使用seata專用的注解 ![](https://img.kancloud.cn/da/2f/da2f3d45ffb73f8aa8707b3a723e6c7f_1706x882.png) 4. 在接口的第一層請求方法加上對應的兩個注解 ![](https://img.kancloud.cn/79/26/79261e25702ce94a5f0c5a6f73834960_1708x1350.png) 5. 這里以docker為例,保持seata服務開啟狀態 ![](https://img.kancloud.cn/0a/71/0a710907cfae26058531a8d25a78b09b_2480x1458.png) 6. 使用sql創建`seata_order`和`seata_storage`的庫 ![](https://img.kancloud.cn/5a/47/5a478ae4c1198a1f435dd1dd0bb43265_672x766.png) 7. 對應數據庫結果如下 ![](https://img.kancloud.cn/7f/85/7f85e68fa445d24d7dd8106e4fd88bea_318x612.png) 8. 兩張表的初始數據如下 ![](https://img.kancloud.cn/e2/d8/e2d8adc163b256718a493d2eb2ac7ee9_1320x290.png) ![](https://img.kancloud.cn/ac/06/ac06c1002470cdc1c7678871929f9153_1312x270.png) <br> ## 服務啟動 1. 啟動blade-seata-order服務 ![](https://img.kancloud.cn/41/d2/41d28e6dfb68411933eb32d0680824fa_1382x1244.png) 2. 啟動完畢后查看控制臺,可以看到服務注冊成功 ![](https://img.kancloud.cn/5a/7a/5a7a992cb97fb435c088fa6bd7a4e5fa_2480x1458.png) 3. 同樣啟動balde-seata-storage服務 ![](https://img.kancloud.cn/00/43/004386abb050693546a7ea779850e9b5_1400x1292.png) 4. 啟動完畢查看控制臺,服務同樣注冊成功 ![](https://img.kancloud.cn/de/06/de06ca249c99bc67a341afe37e8b524c_2480x1458.png) <br> ## 分布式事務測試 1. 啟動核心服務,填入order接口 [POST][http://localhost/blade-seata-order/order/create] 并配置token請求頭 ![](https://img.kancloud.cn/99/5b/995befb8716eab4000f284e851063ba6_1692x1576.png) 2. 先測試普通正常調用的情況,返回操作成功 ![](https://img.kancloud.cn/1d/64/1d64900d3691722f27a514ff0cddd2a3_1680x1284.png) 3. 對應數據變化如下 ![](https://img.kancloud.cn/66/64/6664e1ebdc7692859b41920042e8a1dc_1314x238.png) ![](https://img.kancloud.cn/e3/8e/e38e79ad8fc24a72a719447fbe219b46_1314x270.png) 4. 下面我們調大數值,測試模擬異常的情況,返回創建訂單失敗 ![](https://img.kancloud.cn/7e/80/7e803473d35c12c12d7deef2b1026b72_1692x1280.png) 5. 對應數據沒有變化,那是不是回滾成功了呢?下面我們來看控制臺的數據 ![](https://img.kancloud.cn/66/64/6664e1ebdc7692859b41920042e8a1dc_1314x238.png) ![](https://img.kancloud.cn/e3/8e/e38e79ad8fc24a72a719447fbe219b46_1314x270.png) ## 分布式事務驗證 1. 打開blade-seata-storage的控制臺,可以看到如下日志 ![](https://img.kancloud.cn/e7/6b/e76bf7914911a90710f29758e171a0e3_3500x202.png) 2. 打開docker控制臺,可以看到如下日志 ![](https://img.kancloud.cn/8d/13/8d1305e9a3d75f914b0cfb7a636f7332_2480x1458.png) 3. 再結合數據庫數據沒有變化,說明分布式事務成功回滾 4. 為了再次驗證準確性,我們重復第一次的調用,模擬訂單成功 ![](https://img.kancloud.cn/cc/c8/ccc8dffac97e88ab0110e890bc6a0b79_1676x1222.png) 5. 查看數據庫的數據,發現主鍵從2跳躍至3,說明上一個請求確實是數據入庫又被回滾了 ![](https://img.kancloud.cn/42/24/4224240d9e790018ba7e5a9df80a5eb5_878x280.png) ## 后記 * seata目前已經發布至1.x版本,可以用于生產環境,但每個版本配置變化較大,希望大家跟著bladex的主分支版本來 * 測試下來感覺seata的file模式足夠使用,集群可以考慮file+db模式。 * nacos模式配置使用復雜,目前版本遺留有些許問題,所以暫時不推薦對接nacos,推薦直接使用file+db模式。
                  <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>

                              哎呀哎呀视频在线观看