dtm-php / dtm-client

A PHP coroutine client for distributed transaction manager DTM. 分布式事务管理器 DTM 的 PHP 协程客户端

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tcc 创建的每个子事务的branch_id都为 “01”,导致无法使用子事务屏障

zdywjj opened this issue · comments

public function callBranch($body, string $tryUrl, string $confirmUrl, string $cancelUrl)
    {
        $branchId = $this->branchIdGenerator->generateSubBranchId(); /** 此处创建的每个子事务的 branchId 都为 01 */
        switch ($this->api->getProtocol()) {
            case Protocol::HTTP:
                $this->api->registerBranch([
                    'data' => json_encode($body),
                    'branch_id' => $branchId,
                    'confirm' => $confirmUrl,
                    'cancel' => $cancelUrl,
                    'gid' => TransContext::getGid(),
                    'trans_type' => TransType::TCC,
                ]);

                $branchRequest = new RequestBranch();
                $branchRequest->method = 'POST';
                $branchRequest->url = $tryUrl;
                $branchRequest->branchId = $branchId;
                $branchRequest->op = Operation::TRY;
                $branchRequest->body = $body;
                return $this->api->transRequestBranch($branchRequest);
                break;
          }
    }