update to v1.4.0

This commit is contained in:
zlt
2019-03-15 10:30:51 +08:00
parent 52531b9816
commit bea4650134
78 changed files with 1126 additions and 62 deletions
@@ -0,0 +1,21 @@
package org.txlcn.demo;
import com.codingapi.txlcn.tc.config.EnableDistributedTransaction;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Description:
* Date: 2018/12/25
*
* @author ujued
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableDistributedTransaction
public class ServiceCApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceCApplication.class, args);
}
}
@@ -0,0 +1,24 @@
package org.txlcn.demo.servicec;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* Description:
* Date: 2018/12/25
*
* @author ujued
*/
@RestController
public class DemoController {
@Autowired
private DemoService demoService;
@GetMapping("/rpc")
public String rpc(@RequestParam("value") String value) {
return demoService.rpc(value);
}
}
@@ -0,0 +1,14 @@
package org.txlcn.demo.servicec;
import org.apache.ibatis.annotations.Mapper;
import org.txlcn.demo.common.db.mapper.BaseDemoMapper;
/**
* Description:
* Date: 2018/12/25
*
* @author ujued
*/
@Mapper
public interface DemoMapper extends BaseDemoMapper {
}
@@ -0,0 +1,12 @@
package org.txlcn.demo.servicec;
/**
* Description:
* Date: 2018/12/25
*
* @author ujued
*/
public interface DemoService {
String rpc(String value);
}
@@ -0,0 +1,48 @@
package org.txlcn.demo.servicec;
import com.codingapi.txlcn.common.util.Transactions;
import com.codingapi.txlcn.tc.annotation.DTXPropagation;
import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.codingapi.txlcn.tc.annotation.TccTransaction;
import com.codingapi.txlcn.tc.support.DTXUserControls;
import com.codingapi.txlcn.tracing.TracingContext;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.txlcn.demo.common.db.domain.Demo;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* Description:
* Date: 2018/12/25
*
* @author ujued
*/
@Service
@Slf4j
public class DemoServiceImpl implements DemoService {
@Resource
private DemoMapper demoMapper;
@Override
@LcnTransaction
@Transactional(rollbackFor = Exception.class)
public String rpc(String value) {
Demo demo = new Demo();
demo.setDemoField(value);
demo.setCreateTime(new Date());
demo.setAppName(Transactions.getApplicationId());
demo.setGroupId(TracingContext.tracing().groupId());
demoMapper.save(demo);
if ("456".equals(value)) {
throw new IllegalStateException("by test");
}
return "ok-service-c";
}
}
@@ -0,0 +1,19 @@
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://${zlt.datasource.ip}:3306/txlcn-demo?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
username: ${zlt.datasource.username}
password: ${zlt.datasource.password}
## tx-manager 配置
tx-lcn:
ribbon:
loadbalancer:
dtx:
enabled: true
logger:
enabled: true
driver-class-name: com.mysql.jdbc.Driver
jdbc-url: jdbc:mysql://${zlt.datasource.ip}:3306/tx_logger?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
username: ${zlt.datasource.username}
password: ${zlt.datasource.password}
@@ -0,0 +1,14 @@
server:
port: 12003
zlt:
nacos:
server-addr: 192.168.28.130:8848
spring:
application:
name: txlcn-demo-spring-service-c
cloud:
nacos:
discovery:
server-addr: ${zlt.nacos.server-addr}