diff --git a/README.md b/README.md index f95e503d6..c5c2b4744 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,10 @@ 2. 兼容SpringCloud、Dubbo、motan 3. 使用简单,低依赖,代码完全开源 4. 基于切面的强一致性事务框架 -5. 高可用,模块可以依赖Dubbo或SpringCloud的集群方式做集群化,TxManager也可以做集群化 +5. 高可用,模块可以依赖RPC模块做集群化,TxManager也可以做集群化 6. 支持本地事务和分布式事务共存 7. 支持事务补偿机制,增加事务补偿决策提醒 -8. 增加插件拓展机制 +8. 添加插件拓展机制 ## 原理介绍 diff --git a/tx-client/src/main/java/com/codingapi/tx/netty/handler/TransactionHandler.java b/tx-client/src/main/java/com/codingapi/tx/netty/handler/TransactionHandler.java index 1e54f25dc..c55720952 100644 --- a/tx-client/src/main/java/com/codingapi/tx/netty/handler/TransactionHandler.java +++ b/tx-client/src/main/java/com/codingapi/tx/netty/handler/TransactionHandler.java @@ -84,8 +84,8 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception { /** * 当客户端的所有ChannelHandler中4s内没有write事件,则会触发userEventTriggered方法 * - * @param ctx - * @param evt + * @param ctx 管道 + * @param evt 状态 * @throws Exception 异常数据 */ @Override diff --git a/tx-manager/pom.xml b/tx-manager/pom.xml index 8f581b5a4..a160031c1 100644 --- a/tx-manager/pom.xml +++ b/tx-manager/pom.xml @@ -5,7 +5,7 @@ com.codingapi tx-manager - 4.0.0 + 4.0.1 jar tx-manager diff --git a/tx-manager/src/main/java/com/codingapi/tm/compensate/service/impl/CompensateServiceImpl.java b/tx-manager/src/main/java/com/codingapi/tm/compensate/service/impl/CompensateServiceImpl.java index fbd1d7f8c..791c99569 100644 --- a/tx-manager/src/main/java/com/codingapi/tm/compensate/service/impl/CompensateServiceImpl.java +++ b/tx-manager/src/main/java/com/codingapi/tm/compensate/service/impl/CompensateServiceImpl.java @@ -88,7 +88,7 @@ public void run() { logger.error("补偿回调结果->" + res); if (configReader.isCompensateAuto()) { //自动补偿,是否自动执行补偿 - if ("success".equalsIgnoreCase(res)) { + if (res.contains("success")||res.contains("SUCCESS")) { //自动补偿 autoCompensate(compensateKey, transactionCompensateMsg); } diff --git a/tx-manager/src/main/resources/application.properties b/tx-manager/src/main/resources/application.properties index fd5cc3fab..720af9945 100644 --- a/tx-manager/src/main/resources/application.properties +++ b/tx-manager/src/main/resources/application.properties @@ -38,12 +38,25 @@ tm.socket.port=8898 # 最大socket连接数 tm.socket.maxconnection=100 -#事务补偿记录回调地址(rest api 地址,post json格式) -#json格式如下:{"address":"192.168.0.4:8081","className":"com.example.demo.service.impl.DemoServiceImpl","currentTime":1510490201118,"data":"C5IBLWNvbS5leGFtcGxlLmRlbW8uc2VydmljZS5pbXBsLkRlbW9TZXJ2aWNlSW1wbAwSBHNhdmUbehBqYXZhLmxhbmcuT2JqZWN0GAAQARwjeg9qYXZhLmxhbmcuQ2xhc3MYABABJA==","groupId":"FxGRURve","method":"save","model":"demo1","time":101,"uniqueKey":"1dc8781821747b7050d8ebc23a4fa343"} -tm.compensate.notifyUrl=http://www.baidu.com -#事务自动补偿 + + +#事务自动补偿 (true:开启,false:关闭) +# 说明: +# 开启自动补偿以后,必须要配置 tm.compensate.notifyUrl 地址,仅当tm.compensate.notifyUrl 在请求补偿确认时返回success或者SUCCESS时,才会执行自动补偿,否则不会自动补偿。 +# 关闭自动补偿,当出现数据时也会 tm.compensate.notifyUrl 地址。 +# 当tm.compensate.notifyUrl 无效时,不影响TxManager运行,仅会影响自动补偿。 tm.compensate.auto=false -#补偿失败,再次尝试间隔(秒) + +#事务补偿记录回调地址(rest api 地址,post json格式) +#json格式如下: +#该请求是在通知补偿事务时的补偿记录数据请求 +#{"groupId":"TtQxTwJP","action":"compensate","json":"{\"address\":\"133.133.5.100:8081\",\"className\":\"com.example.demo.service.impl.DemoServiceImpl\",\"currentTime\":1511356150413,\"data\":\"C5IBLWNvbS5leGFtcGxlLmRlbW8uc2VydmljZS5pbXBsLkRlbW9TZXJ2aWNlSW1wbAwSBHNhdmUbehBqYXZhLmxhbmcuT2JqZWN0GAAQARwjeg9qYXZhLmxhbmcuQ2xhc3MYABABJCo/cHVibGljIGludCBjb20uZXhhbXBsZS5kZW1vLnNlcnZpY2UuaW1wbC5EZW1vU2VydmljZUltcGwuc2F2ZSgp\",\"groupId\":\"TtQxTwJP\",\"methodStr\":\"public int com.example.demo.service.impl.DemoServiceImpl.save()\",\"model\":\"demo1\",\"state\":0,\"time\":36,\"txGroup\":{\"groupId\":\"TtQxTwJP\",\"hasOver\":1,\"isCommit\":0,\"list\":[{\"address\":\"133.133.5.100:8899\",\"isCommit\":0,\"isGroup\":0,\"kid\":\"wnlEJoSl\",\"methodStr\":\"public int com.example.demo.service.impl.DemoServiceImpl.save()\",\"model\":\"demo2\",\"modelIpAddress\":\"133.133.5.100:8082\",\"modelName\":\"/133.133.5.100:64153\",\"notify\":1,\"uniqueKey\":\"bc13881a5d2ab2ace89ae5d34d608447\"}],\"nowTime\":0,\"startTime\":1511356150379,\"state\":1},\"uniqueKey\":\"be6eea31e382f1f0878d07cef319e4d7\"}"} +#该请求是在执行完补偿事务以后的反馈结果请求 +#{"resState":true,"groupId":"TtQxTwJP","action":"notify"} + +tm.compensate.notifyUrl=http://ip:port/path + +#补偿失败,再次尝试间隔(秒),最大尝试次数3次,当超过3次即为补偿失败。 tm.compensate.tryTime=30 diff --git a/tx-manager/src/main/resources/static/index.html b/tx-manager/src/main/resources/static/index.html index 9600b562a..d041cd681 100644 --- a/tx-manager/src/main/resources/static/index.html +++ b/tx-manager/src/main/resources/static/index.html @@ -2,7 +2,7 @@ - TxManager v4.0.0 + TxManager v4.0.1 @@ -24,7 +24,7 @@
-

TxManagerV4.0.0 服务已启动

+

TxManagerV4.0.1 服务已启动

diff --git a/tx-manager/src/main/resources/static/log.html b/tx-manager/src/main/resources/static/log.html index 4853ae9df..84aa09d76 100644 --- a/tx-manager/src/main/resources/static/log.html +++ b/tx-manager/src/main/resources/static/log.html @@ -48,13 +48,13 @@
- + - + @@ -67,12 +67,11 @@ -
+
-
模块名称补偿数量条数
+
- - + @@ -90,11 +89,17 @@
+ + + + + + - + diff --git a/tx-manager/src/main/resources/static/static/log.js b/tx-manager/src/main/resources/static/static/log.js index 730219f3b..f4c0e9347 100644 --- a/tx-manager/src/main/resources/static/static/log.js +++ b/tx-manager/src/main/resources/static/static/log.js @@ -10,7 +10,7 @@ var init = function () { var tr = '' + '' + - '' + + '' + ''; list.append(tr); }
记录时间 执行方法执行时间(毫秒)执行时间 操作
' + v['name'] + '' + v['count'] + '' + v['count'] + '