update to v1.4.0
This commit is contained in:
+21
@@ -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 ServiceBApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceBApplication.class, args);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
@RestController
|
||||
public class DemoController {
|
||||
|
||||
@Autowired
|
||||
private DemoService demoService;
|
||||
|
||||
@GetMapping("/rpc")
|
||||
public String rpc(@RequestParam("value") String value, HttpServletRequest servletRequest) {
|
||||
return demoService.rpc(value);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
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 {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2018/12/25
|
||||
*
|
||||
* @author ujued
|
||||
*/
|
||||
public interface DemoService {
|
||||
|
||||
String rpc(String value);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.txlcn.demo.serviceb;
|
||||
|
||||
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.TxcTransaction;
|
||||
import com.codingapi.txlcn.tracing.TracingContext;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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.setGroupId(TracingContext.tracing().groupId());
|
||||
demo.setDemoField(value);
|
||||
demo.setAppName(Transactions.getApplicationId());
|
||||
demo.setCreateTime(new Date());
|
||||
demoMapper.save(demo);
|
||||
return "ok-service-b";
|
||||
}
|
||||
}
|
||||
@@ -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: 12002
|
||||
|
||||
zlt:
|
||||
nacos:
|
||||
server-addr: 192.168.28.130:8848
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: txlcn-demo-spring-service-b
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${zlt.nacos.server-addr}
|
||||
Reference in New Issue
Block a user