package com.yeshi.buwan.service.manager;
|
|
import com.ks.goldcorn.pojo.DO.GoldCornGetSource;
|
import com.ks.goldcorn.service.remote.GoldCornGetSourceService;
|
import com.yeshi.buwan.dao.user.LoginUserDao;
|
import com.yeshi.buwan.domain.user.LoginUser;
|
import io.seata.core.context.RootContext;
|
import io.seata.spring.annotation.GlobalTransactional;
|
import org.apache.dubbo.config.annotation.Reference;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.Resource;
|
|
@Component
|
public class SeataManagerTest {
|
|
@Resource
|
private LoginUserDao loginUserDao;
|
|
@Reference(version = "1.0",check = false)
|
private GoldCornGetSourceService goldCornGetSourceService;
|
|
@GlobalTransactional(timeoutMills = 30000, name = "buwan-order", rollbackFor = Exception.class)
|
public void addGetResource() throws Exception {
|
// loginUserDao.selectByPrimaryKeyForUpdate("50134");
|
System.out.println("开始全局事务,XID = " + RootContext.getXID());
|
LoginUser loginUser = new LoginUser();
|
loginUser.setId("50134");
|
loginUser.setName("test9");
|
loginUserDao.updateSelective(loginUser);
|
|
GoldCornGetSource get = new GoldCornGetSource();
|
get.setAppId(15L);
|
get.setSourceCode("test5");
|
get.setSourceName("测试");
|
get.setGoldCorn(1);
|
|
goldCornGetSourceService.addSource(get);
|
throw new Exception("手动报错");
|
}
|
|
}
|