samples/seata/gateway/conf.yaml
- name: dgp.filter.http.seata config: addressing: service-a serverAddressing: "localhost:8091" commitRetryCount: 5 rollbackRetryCount: 5 clientParameters: time: 10s timeout: 1s permitWithoutStream: true transactionInfos: - requestPath: "/service-a/begin" timeout: 60000
samples/seata/gateway/conf.yaml
- name: dgp.filter.http.seata config: addressing: service-b serverAddressing: "localhost:8091" commitRetryCount: 5 rollbackRetryCount: 5 clientParameters: time: 10s timeout: 1s permitWithoutStream: true tccResources: - prepareRequestPath: "/service-b/try" commitRequestPath: "/service-b/confirm" rollbackRequestPath: "/service-b/cancel"
tccResources 配置了 TCC 分支事务对应的接口。如果请求 url 与 prepareRequestPath
匹配,并且 requestHeader 中存在 key x_seata_xid
,则 Pixiu 将向 seata tc server 注册分支事务。当全 局事务提交时,seata tc server 会通知 Pixiu 提交分支事务,Pixiu 将自动调用 commitRequestPath
对应的接口。全局回滚时,seata tc server 会通知 Pixiu 回滚分支事务,Pixiu 将自动调用 rollbackRequestPath
对应的接口来回滚。
需要一个编译好的 Pixiu 程序
cd ${projectpath}/cmd/pixiu/pixiu go build
需要运行 seata tc server,地址:https://github.com/opentrx/seata-golang/tree/v2
示例代码目录
${targetpath} = ${projectpath}/examples/codes/seata/
mv main ${targetpath}/ cd ${targetpath}
main // 编译完成的 Pixiu 程序 |-- server_a |-- |-- server_a.go |-- server_b |-- |-- server_b.go |-- server_c |-- |-- server_c.go |-- conf.yaml
参考 https://github.com/opentrx/seata-golang/tree/v2
./pixiu gateway start -c conf.yaml