enhancement #I3CTUK 每个组件的对slot index的存储,换成阿里的TTL

This commit is contained in:
zendwang 2021-03-26 17:05:05 +08:00
parent c6545469f6
commit 300dd49c62
3 changed files with 13 additions and 5 deletions

View File

@ -76,5 +76,9 @@
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -10,7 +10,7 @@ package com.yomahub.liteflow.core;
import cn.hutool.core.date.StopWatch;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.ttl.TransmittableThreadLocal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,8 +26,6 @@ import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.monitor.MonitorBus;
import com.yomahub.liteflow.spring.ComponentScaner;
/**
* 普通组件抽象类
* @author Bryan.Zhang
@ -36,7 +34,7 @@ public abstract class NodeComponent {
private static final Logger LOG = LoggerFactory.getLogger(NodeComponent.class);
private InheritableThreadLocal<Integer> slotIndexTL = new InheritableThreadLocal<Integer>();
private TransmittableThreadLocal<Integer> slotIndexTL = new TransmittableThreadLocal<Integer>();
@Autowired(required = false)
private MonitorBus monitorBus;
@ -44,7 +42,7 @@ public abstract class NodeComponent {
private String nodeId;
//是否结束整个流程这个只对串行流程有效并行流程无效
private InheritableThreadLocal<Boolean> isEndTL = new InheritableThreadLocal<>();
private TransmittableThreadLocal<Boolean> isEndTL = new TransmittableThreadLocal<>();
public void execute() throws Exception{
Slot slot = this.getSlot();

View File

@ -51,6 +51,7 @@
<curator.version>2.12.0</curator.version>
<junit.version>4.12</junit.version>
<hutool-core.version>5.3.10</hutool-core.version>
<transmittable-thread-local.version>2.12.1</transmittable-thread-local.version>
</properties>
<dependencyManagement>
@ -125,6 +126,11 @@
<artifactId>hutool-core</artifactId>
<version>${hutool-core.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>transmittable-thread-local</artifactId>
<version>${transmittable-thread-local.version}</version>
</dependency>
</dependencies>
</dependencyManagement>