执行business模块test/java目录下的business.http文件,对接口发起请求。
Content-Type: application/json { "userId" : "user123", "commodityCode" : "cola", "count" : 2, "amount" : 5.0 }
各数据库数据变化
mysql> use storage; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from storage; +----+----------------+------+-------+ | id | commodity_code | name | count | +----+----------------+------+-------+ | 1 | cola | ???? | 1998 | +----+----------------+------+-------+ 1 row in set (0.00 sec) mysql> use account; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from account; +----+---------+---------+ | id | user_id | amount | +----+---------+---------+ | 1 | user123 | 1245.00 | +----+---------+---------+ 1 row in set (0.00 sec) mysql> use order; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from order; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1 mysql> select * from `order`; +----+----------------------------------+---------+------+-------+--------+ | id | order_no | user_id | code | count | amount | +----+----------------------------------+---------+------+-------+--------+ | 5 | dbde6ebfd72b4ad5aeba67d67ade6894 | user123 | cola | 2 | 5.00 | +----+----------------------------------+---------+------+-------+--------+ 1 row in set (0.00 sec)
各应用下二阶段提交情况,下面日志以Storage应用为例。
2020-12-21 16:35:41.357 INFO 5123 --- [:20881-thread-2] c.m.storage.provider.StorageApiImpl : storage-全局事务,XID = 172.20.0.2:8091:84324557325869056 2020-12-21 16:35:41.431 INFO 5123 --- [:20881-thread-2] i.s.c.rpc.netty.RmNettyRemotingClient : will register resourceId:jdbc:mysql://localhost:3306/storage 2020-12-21 16:35:41.440 INFO 5123 --- [ctor_RMROLE_1_1] io.seata.rm.AbstractRMHandler : the rm client received response msg [version=1.5.0-SNAPSHOT,extraData=null,identified=true,resultCode=null,msg=null] from tc server. 2020-12-21 16:35:41.444 DEBUG 5123 --- [:20881-thread-2] c.m.s.dao.StorageDao.decreaseStorage : ==> Preparing: update storage set count = count - ? where commodity_code = ? 2020-12-21 16:35:41.535 DEBUG 5123 --- [:20881-thread-2] c.m.s.dao.StorageDao.decreaseStorage : ==> Parameters: 2(Integer), cola(String) 2020-12-21 16:35:41.665 DEBUG 5123 --- [:20881-thread-2] c.m.s.dao.StorageDao.decreaseStorage : <== Updates: 1 2020-12-21 16:35:43.345 INFO 5123 --- [h_RMROLE_1_1_16] i.s.c.r.p.c.RmBranchCommitProcessor : rm client handle branch commit process:xid=172.20.0.2:8091:84324557325869056,branchId=84324559649513472,branchType=AT,resourceId=jdbc:mysql://localhost:3306/storage,applicationData=null 2020-12-21 16:35:43.348 INFO 5123 --- [h_RMROLE_1_1_16] io.seata.rm.AbstractRMHandler : Branch committing: 172.20.0.2:8091:84324557325869056 84324559649513472 jdbc:mysql://localhost:3306/storage null 2020-12-21 16:35:43.349 INFO 5123 --- [h_RMROLE_1_1_16] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed 2020-12-21 16:35:43.369 INFO 5123 --- [h_RMROLE_1_2_16] i.s.c.r.p.c.RmBranchCommitProcessor : rm client handle branch commit process:xid=172.20.0.2:8091:84324557325869056,branchId=84324560404488192,branchType=AT,resourceId=jdbc:mysql://localhost:3306/storage,applicationData=null 2020-12-21 16:35:43.369 INFO 5123 --- [h_RMROLE_1_2_16] io.seata.rm.AbstractRMHandler : Branch committing: 172.20.0.2:8091:84324557325869056 84324560404488192 jdbc:mysql://localhost:3306/storage null 2020-12-21 16:35:43.369 INFO 5123 --- [h_RMROLE_1_2_16] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed 2020-12-21 16:35:43.378 INFO 5123 --- [h_RMROLE_1_3_16] i.s.c.r.p.c.RmBranchCommitProcessor : rm client handle branch commit process:xid=172.20.0.2:8091:84324557325869056,branchId=84324560530317312,branchType=AT,resourceId=jdbc:mysql://localhost:3306/storage,applicationData=null 2020-12-21 16:35:43.378 INFO 5123 --- [h_RMROLE_1_3_16] io.seata.rm.AbstractRMHandler : Branch committing: 172.20.0.2:8091:84324557325869056 84324560530317312 jdbc:mysql://localhost:3306/storage null 2020-12-21 16:35:43.378 INFO 5123 --- [h_RMROLE_1_3_16] io.seata.rm.AbstractRMHandler : Branch commit result: PhaseTwo_Committed
异常流程-模拟用户下单,看下各应用的二阶段提交日志。