springcloud分布式事务txlcn

采用txlcn实现分布式事务 锁采用的是zk锁

	
	        
	            com.codingapi.txlcn
	            txlcn-tc
	        
	        
	            com.codingapi.txlcn
	            txlcn-txmsg-netty
	        
	         
        
            org.apache.curator
            curator-recipes
        

微服务a方法上面添加注解

@SpringBootApplication
@EnableFeignClients
@EnableAsync
@MapperScan("com.risk.test.mapper")
@EnableTransactionManagement //该注解主要注意 调用分布式事务时要
@EnableCaching
public class AServiceApplication{..
 @LcnTransaction
   @Transactional(rollbackFor = Exception.class)
   @Override
   public List luckDraw(Long userId, GamePrizeDTO gamePrizeDTO, String price) throws CustomExcpion{...

如果微服务A方法内有调用别的微服务的方法时 被调用的微服务B的方法上也需要注释
微服务a方法上面添加注解

@SpringBootApplication
@EnableCaching
@MapperScan("com.risk.test.mapper")
@EnableTransactionManagement //该注解主要注意  调用分布式事务时要
@EnableDistributedTransaction //该注解主要注意 被调用分布式事务时要
@EnableFeignClients
public class BApplication
@LcnTransaction
   @Transactional(rollbackFor = Exception.class)
   @Override
   public boolean subUserGold(UserGoldUpdateDTO userGoldUpdateDTO) throws CustomExcpion {...

你可能感兴趣的:(java后台框架)