通讯指令手册

TxClient 与 TxManager 通讯指令说明文档

通讯指令数据包格式为Json格式

Json结构说明:

字段数据类型说明
keystring请求唯一标示
remoteKeystring请求资源方标示key
msgobject请求包数据体
msg.actionstring请求业务方法名
msg.stateint请求状态 100:发起请求,200:响应成功,500:响应失败
msg.groupIdstring事务组Id
msg.bytesbyte[]序列化请求数据

示例数据包:

请求包

{
	"key": "25303248287617950",
	"msg": {
		"action": "joinGroup",
		"state": 100,
		"bytes": "ChEyNTMwMzIyNDYxMjczODg4OBIgNGQ1NTcwMjc3Yzg1OTI5OTI5YWUxNDBiNjFlNjA3ZjAaA3R4Yw==",
		"groupId": "25303224612738888"
	},
	"remoteKey": "/127.0.0.1:8070"
}

响应包

{
	"key": "25303248287617950",
	"msg": {
		"action": "joinGroup",
		"state": 200,
		"groupId": "25303224612738888"
	},
	"remoteKey": "/127.0.0.1:59413"
}

  1. 创建事务组指令

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringcreateGroup创建事务组key
stateint100请求状态
groupIdstring1234567890事务组Id

响应参数:

字段数据类型说明
actionstringcreateGroup创建事务组
stateint200响应成功
groupIdstring1234567890事务组Id
  1. 加入事务组指令

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringjoinGroup加入事务组
stateint100请求状态
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
unitIdstring1234567890事务单元Id
unitTypestringlcn事务类型(lcn/txc/tcc)
remoteKeystring/127.0.0.1:8070请求资源方标示key

响应参数:

字段数据类型说明
actionstringjoinGroup加入事务组
stateint200响应成功
groupIdstring1234567890事务组Id
  1. 通知事务组指令

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringnotifyGroup通知事务组
stateint100请求状态
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
stateint0 或 1代表发起方正常或者异常执行

响应参数:

字段数据类型说明
actionstringnotifyGroup通知事务组
stateint200响应成功
groupIdstring1234567890事务组Id
  1. 通知事务单元指令

请求方向:TxManager->TxClient

请求msg对象参数:

字段数据类型说明
actionstringnotifyUnit通知事务单元
stateint100请求状态
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
unitIdstring1234567890事务单元Id
unitTypestringlcn事务类型(lcn/txc/tcc)
stateint0 或 10 代表回滚,1代表提交

响应参数:

字段数据类型说明
actionstringnotifyUnit通知事务组
stateint200响应成功
groupIdstring1234567890事务组Id
  1. 事务单元检查事务状态

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringaskTransactionState通知事务组
stateint100请求状态
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
unitIdstring1234567890事务单元Id

响应参数:

字段数据类型说明
actionstringaskTransactionState通知事务组
stateint200响应成功
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式(该序列化直接对Short对象做了序列化,无Object对象)

数据类型说明
int1、0、-10 代表回滚,1代表提交,-1将添加到异常状态
  1. 心跳指令

请求方向:TxManager->TxClient

格式如下:

{"key":"252356025399579923","msg":{"action":"h","state":1000}}
  1. 通知加入新的TxManager

请求方向:TxManager->TxClient

请求msg对象参数:

字段数据类型说明
actionstringnewTxManager通知事务组
stateint100请求状态
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
hoststring127.0.0.1TxManager服务地址
portint8082TxManager服务端口

无需响应

  1. 客户端上报异常状态

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringwriteException通知事务组
stateint100请求状态
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
unitIdstring1234567890事务单元Id
registrarshort-1 0 1 2异常情况 -1:未知, 0:TxManager通知事务,1:TxClient查询事务状态, 2:事务发起方通知事务组
transactionStateshort1234567890事务单元Id

无需响应

  1. 通知客户端获取事务切面日志

请求方向:TxManager->TxClient

请求msg对象参数:

字段数据类型说明
actionstringgetAspectLog通知事务组
stateint100请求状态
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
unitIdstring1234567890事务单元Id

响应参数:

字段数据类型说明
actionstringgetAspectLog通知事务组
stateint200响应成功
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式(该序列化直接对Json对象做了序列化,无Object对象)

数据类型说明
JsonObject{key:value}切面日志json格式
  1. 客户端初始化指令

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringinitClient通知事务单元
stateint100请求状态
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
appNamestringdemo1模块名称

响应参数:

字段数据类型说明
actionstringinitClient通知事务组
stateint200响应成功
groupIdstring1234567890事务组Id
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
appNamestringdemo1模块名称
dtxTimeint30000分布式事务执行最大时间(单位:毫秒)
tmRpcTimeoutint30000TM RPC 超时时间(单位:毫秒)
seqLenint12雪花算法ID序列长度
分配的机器IDint1雪花算法分配的机器ID
  1. TXC询问分布式锁

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringqdtxl询问分布式锁
stateint100请求状态
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
groupIdstring1234567890事务组Id
contextIdstring1234567890应用模块位于标识
locksSet{"123","456"}锁的数据内容
lockTypeint1共享锁:2,排他锁:1

响应参数:

字段数据类型说明
actionstringinitClient通知事务组
stateint200响应成功
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式为boolean类型,false | true

  1. TXC释放分布式锁

请求方向:TxClient->TxManager

请求msg对象参数:

字段数据类型说明
actionstringrdtxl释放分布式锁
stateint100请求状态
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式

字段数据类型说明
contextIdstring1234567890应用模块位于标识
locksSet{"123","456"}锁的数据内容

响应参数:

字段数据类型说明
actionstringinitClient通知事务组
stateint200响应成功
bytesbyte[]1234567890==序列化请求数据包

序列化数据包内容格式为boolean类型,false | true

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值