From 62d7509ff435234148c8dc74092285a7c5c54919 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Mon, 26 Jul 2021 22:05:47 +0800 Subject: [PATCH] fix xa test --- README.md | 15 +++++++++++++-- examples/main_xa.go | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d758aa9..f78fd5a 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,9 @@ Configure mysql: Refer to [examples/quick_start.go](./examples/quick_start.go) -## [sub-transaction barrier](./doc/barrier-en.md) +### [sub-transaction barrier](./doc/barrier-en.md) -## [protocol](./doc/protocol-en.md) +### [protocol](./doc/protocol-en.md) ### Wechat Group @@ -98,3 +98,14 @@ If you think this project is good, or helpful to you, please give a star! ivydad eglass + +### Following is keyword for SEO + +分布式事务框架 + +事务消息 + +可靠消息 + +微服务 + diff --git a/examples/main_xa.go b/examples/main_xa.go index 9aae0ba..daa2090 100644 --- a/examples/main_xa.go +++ b/examples/main_xa.go @@ -65,7 +65,7 @@ func XaFireRequest() string { func xaTransIn(c *gin.Context) (interface{}, error) { err := XaClient.XaLocalTransaction(c, func(db *common.DB, xa *dtmcli.Xa) (rerr error) { req := reqFrom(c) - if req.TransInResult != "SUCCESS" { + if req.TransInResult == "FAILURE" { return fmt.Errorf("tranIn FAILURE") } dbr := db.Exec("update user_account set balance=balance+? where user_id=?", req.Amount, 2) @@ -81,7 +81,7 @@ func xaTransIn(c *gin.Context) (interface{}, error) { func xaTransOut(c *gin.Context) (interface{}, error) { err := XaClient.XaLocalTransaction(c, func(db *common.DB, xa *dtmcli.Xa) (rerr error) { req := reqFrom(c) - if req.TransOutResult != "SUCCESS" { + if req.TransOutResult == "FAILURE" { return fmt.Errorf("tranOut failed") } dbr := db.Exec("update user_account set balance=balance-? where user_id=?", req.Amount, 1)