mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
commit
2f3460f3f5
2
pom.xml
2
pom.xml
@ -80,7 +80,7 @@
|
||||
|
||||
<properties>
|
||||
<!-- Project revision -->
|
||||
<revision>2.2.3-SNAPSHOT</revision>
|
||||
<revision>2.2.4-SNAPSHOT</revision>
|
||||
|
||||
<!-- Dependency Versions -->
|
||||
<spring-cloud-commons.version>2.2.5.RELEASE</spring-cloud-commons.version>
|
||||
|
@ -18,7 +18,7 @@
|
||||
<description>Spring Cloud Alibaba Dependencies</description>
|
||||
|
||||
<properties>
|
||||
<revision>2.2.3.RELEASE</revision>
|
||||
<revision>2.2.4-SNAPSHOT</revision>
|
||||
<sentinel.version>1.8.0</sentinel.version>
|
||||
<seata.version>1.3.0</seata.version>
|
||||
<nacos.client.version>1.3.3</nacos.client.version>
|
||||
|
@ -207,6 +207,7 @@ Metadata|spring.cloud.nacos.discovery.metadata||Extended data, Configure using M
|
||||
log name|spring.cloud.nacos.discovery.log-name||
|
||||
endpoint|spring.cloud.nacos.discovery.endpoint||The domain name of a service, through which the server address can be dynamically obtained.
|
||||
Integration Ribbon|ribbon.nacos.enabled|true|
|
||||
enabled|spring.cloud.nacos.discovery.enabled|true|The switch to enable or disable nacos service discovery
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,8 @@ spring.cloud.nacos.discovery.server-addr=localhost:8848
|
||||
|
||||
#feign.hystrix.enabled=true
|
||||
#feign.sentinel.enabled=true
|
||||
feign.client.config.default.connectTimeout=10000
|
||||
feign.client.config.default.readTimeout=10000
|
||||
|
||||
logging.level.io.seata=debug
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>order-service</artifactId>
|
||||
<name>Spring Cloud Starter Alibaba Seata Example - Business Service</name>
|
||||
<name>Spring Cloud Starter Alibaba Seata Example - Order Service</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
@ -53,4 +53,4 @@
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
@ -36,7 +36,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
*
|
||||
* @author xiaojing
|
||||
*/
|
||||
@Endpoint(id = "nacos-config")
|
||||
@Endpoint(id = "nacosconfig")
|
||||
public class NacosConfigEndpoint {
|
||||
|
||||
private final NacosConfigProperties properties;
|
||||
|
@ -32,7 +32,7 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
@ -59,7 +59,7 @@ public class NacosDiscoveryClientConfiguration {
|
||||
matchIfMissing = true)
|
||||
public NacosWatch nacosWatch(NacosServiceManager nacosServiceManager,
|
||||
NacosDiscoveryProperties nacosDiscoveryProperties,
|
||||
ObjectProvider<TaskScheduler> taskExecutorObjectProvider) {
|
||||
ObjectProvider<ThreadPoolTaskScheduler> taskExecutorObjectProvider) {
|
||||
return new NacosWatch(nacosServiceManager, nacosDiscoveryProperties,
|
||||
taskExecutorObjectProvider);
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
|
||||
import com.alibaba.cloud.nacos.NacosServiceManager;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.api.naming.NamingService;
|
||||
import com.alibaba.nacos.api.naming.listener.Event;
|
||||
import com.alibaba.nacos.api.naming.listener.EventListener;
|
||||
@ -41,7 +40,6 @@ import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
/**
|
||||
@ -66,14 +64,15 @@ public class NacosWatch implements ApplicationEventPublisherAware, SmartLifecycl
|
||||
|
||||
private final NacosDiscoveryProperties properties;
|
||||
|
||||
private final TaskScheduler taskScheduler;
|
||||
private final ThreadPoolTaskScheduler taskScheduler;
|
||||
|
||||
public NacosWatch(NacosServiceManager nacosServiceManager,
|
||||
NacosDiscoveryProperties properties,
|
||||
ObjectProvider<TaskScheduler> taskScheduler) {
|
||||
ObjectProvider<ThreadPoolTaskScheduler> taskScheduler) {
|
||||
this.nacosServiceManager = nacosServiceManager;
|
||||
this.properties = properties;
|
||||
this.taskScheduler = taskScheduler.getIfAvailable(NacosWatch::getTaskScheduler);
|
||||
this.taskScheduler = taskScheduler.stream().findAny()
|
||||
.orElseGet(NacosWatch::getTaskScheduler);
|
||||
}
|
||||
|
||||
private static ThreadPoolTaskScheduler getTaskScheduler() {
|
||||
@ -156,7 +155,7 @@ public class NacosWatch implements ApplicationEventPublisherAware, SmartLifecycl
|
||||
if (this.watchFuture != null) {
|
||||
// shutdown current user-thread,
|
||||
// then the other daemon-threads will terminate automatic.
|
||||
((ThreadPoolTaskScheduler) this.taskScheduler).shutdown();
|
||||
this.taskScheduler.shutdown();
|
||||
this.watchFuture.cancel(true);
|
||||
}
|
||||
|
||||
@ -167,7 +166,7 @@ public class NacosWatch implements ApplicationEventPublisherAware, SmartLifecycl
|
||||
namingService.unsubscribe(properties.getService(), properties.getGroup(),
|
||||
Arrays.asList(properties.getClusterName()), eventListener);
|
||||
}
|
||||
catch (NacosException e) {
|
||||
catch (Exception e) {
|
||||
log.error("namingService unsubscribe failed, properties:{}", properties,
|
||||
e);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||
*
|
||||
* @author xiaojing
|
||||
*/
|
||||
@Endpoint(id = "nacos-discovery")
|
||||
@Endpoint(id = "nacosdiscovery")
|
||||
public class NacosDiscoveryEndpoint {
|
||||
|
||||
private static final Logger log = LoggerFactory
|
||||
|
@ -36,6 +36,7 @@ import io.seata.core.context.RootContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
@ -156,11 +157,15 @@ public class SeataHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
|
||||
public K call() throws Exception {
|
||||
try {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
RootContext.bind(xid);
|
||||
if (!StringUtils.isEmpty(xid)) {
|
||||
RootContext.bind(xid);
|
||||
}
|
||||
return actual.call();
|
||||
}
|
||||
finally {
|
||||
RootContext.unbind();
|
||||
if (!StringUtils.isEmpty(xid)) {
|
||||
RootContext.unbind();
|
||||
}
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user