You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/08/16 07:06:08 UTC
[GitHub] [incubator-shardingsphere] huangjian888 opened a new issue #2881:
shardingsphere+seata+dubbo No Rollback
huangjian888 opened a new issue #2881: shardingsphere+seata+dubbo No Rollback
URL: https://github.com/apache/incubator-shardingsphere/issues/2881
I have consulted relevant documents and issues,but no solution has been found.
The project uses shardingsphere + Seata + Dubbo,but does not roll back using Dubbo
Dubbo provider Code:
import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.company.spring.boot.shardingsphere.seata.modules.entity.OrderEntity;
import com.company.spring.boot.shardingsphere.seata.modules.mapper.OrderMapper;
import com.company.spring.boot.shardingsphere.seata.modules.service.IOrderService;
import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderEntity> implements IOrderService {
@Override
public void insertOrder(OrderEntity orderEntity) {
System.out.println("XID:"+ RootContext.getXID());
baseMapper.insert(orderEntity);
}
}
Dubbo consumer Code:
import com.alibaba.dubbo.config.annotation.Reference;
import com.company.spring.boot.shardingsphere.seata.modules.entity.OrderEntity;
import com.company.spring.boot.shardingsphere.seata.modules.service.IBusinessService;
import com.company.spring.boot.shardingsphere.seata.modules.service.IOrderService;
import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
import org.springframework.stereotype.Service;
@Service
public class BusinessServiceImpl implements IBusinessService {
@Reference(check = false,mock = "com.company.spring.boot.shardingsphere.seata.modules.mock.IOrderServiceMock")
IOrderService orderService;
@Override
@GlobalTransactional(name = "dubbo-purchase")
public void purchase(){
TransactionTypeHolder.set(TransactionType.BASE);
OrderEntity orderEntity = new OrderEntity();
orderEntity.setOrderId(123);
orderEntity.setStatus("seata");
orderEntity.setUserId(123);
orderService.insertOrder(orderEntity);
System.out.println("XID:"+ RootContext.getXID());
throw new RuntimeException("回滚测试");
}
}
@GlobalTransactional

GlobalTransactionScanner Class has been delete initClient Function
The query log found that consumer had printed

But the provider did not roll back the message
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services