提交 1e59d20f authored 作者: 陈世营's avatar 陈世营

base transaction

上级 b6dfbdf4
...@@ -3,6 +3,7 @@ package com.loit.shardingsphere.seata.nacos.feign.modules.service.impl; ...@@ -3,6 +3,7 @@ package com.loit.shardingsphere.seata.nacos.feign.modules.service.impl;
import com.loit.shardingsphere.seata.nacos.feign.modules.entity.OrderEntity; import com.loit.shardingsphere.seata.nacos.feign.modules.entity.OrderEntity;
import com.loit.shardingsphere.seata.nacos.feign.modules.service.IBusinessService; import com.loit.shardingsphere.seata.nacos.feign.modules.service.IBusinessService;
import com.loit.shardingsphere.seata.nacos.feign.modules.service.IOrderService; import com.loit.shardingsphere.seata.nacos.feign.modules.service.IOrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType; import org.apache.shardingsphere.transaction.annotation.ShardingTransactionType;
import org.apache.shardingsphere.transaction.core.TransactionType; import org.apache.shardingsphere.transaction.core.TransactionType;
import org.apache.shardingsphere.transaction.core.TransactionTypeHolder; import org.apache.shardingsphere.transaction.core.TransactionTypeHolder;
...@@ -22,14 +23,13 @@ public class BusinessServiceImpl implements IBusinessService { ...@@ -22,14 +23,13 @@ public class BusinessServiceImpl implements IBusinessService {
* @param userId * @param userId
*/ */
@Override @Override
@ShardingTransactionType(TransactionType.LOCAL) @ShardingTransactionType(TransactionType.BASE)
//@GlobalTransactional @GlobalTransactional
@Transactional
public void purchase(Long userId) { public void purchase(Long userId) {
if (userId == null) { if (userId == null) {
return; return;
} }
TransactionTypeHolder.set(TransactionType.LOCAL); TransactionTypeHolder.set(TransactionType.BASE);
OrderEntity orderEntity = new OrderEntity(); OrderEntity orderEntity = new OrderEntity();
orderEntity.setOrderId(userId); orderEntity.setOrderId(userId);
orderEntity.setStatus("seata"); orderEntity.setStatus("seata");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论