Commit ce5f5a2c by huangfusuper

后置回调改为异步

parent 873ec79b
package com.byit.conf;
import com.byit.util.ThreadPoolUtil;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @author Administrator
*/
public class RunRecordingThreadPool {
/**
* 实例执行生命周期后置回调的线程
*/
public static ThreadPoolExecutor RUN_RECORDING_THREAD_POOL = ThreadPoolUtil.createCutomizeThreadPoolExecutor("RunRecordingThreadPool",Runtime.getRuntime().availableProcessors()*2,100,60, TimeUnit.SECONDS,1024);
}
package com.byit.service.mapservice.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.byit.conf.RunRecordingThreadPool;
import com.byit.dto.RunRecordingWrapped;
import com.byit.enums.EmailEnum;
import com.byit.enums.FlowPropertyEnum;
......@@ -151,6 +152,8 @@ public class RunRecordingAndLogServiceImpl implements RunRecordingAndLogService,
runRecordingService.updateRunRecordingById(virtualRunRecording);
}
RunRecordingThreadPool.RUN_RECORDING_THREAD_POOL.submit(() ->{
Map<String, InstanceRunTheLifeCycleCallback> beansOfType = SpringUtil.getBeansOfType(InstanceRunTheLifeCycleCallback.class);
Set<Map.Entry<String, InstanceRunTheLifeCycleCallback>> entries = beansOfType.entrySet();
//回调生命周期
......@@ -158,6 +161,9 @@ public class RunRecordingAndLogServiceImpl implements RunRecordingAndLogService,
log.info("-------------【开始回调周期{}后置】---------------",entry.getKey());
entry.getValue().postProcessBeforeInitialization(runRecording);
}
});
});
......
package com.byit.thread.helper;
import com.byit.conf.RunRecordingThreadPool;
import com.byit.enums.EmailEnum;
import com.byit.enums.NodeRunStatusPropertyEnum;
import com.byit.enums.RunRecordingEnum;
......@@ -77,6 +78,8 @@ public class ClosingExampleThreadRunHelper extends BaseThreadRunHelper implement
runRecording.setEndTime(new Date());
runRecordingService.updateRunRecordingById(runRecording);
applicationEventPublisher.publishEvent(new EndFlowEvent(this,runRecording));
RunRecordingThreadPool.RUN_RECORDING_THREAD_POOL.submit(() ->{
Map<String, InstanceRunTheLifeCycleCallback> beansOfType = SpringUtil.getBeansOfType(InstanceRunTheLifeCycleCallback.class);
Set<Map.Entry<String, InstanceRunTheLifeCycleCallback>> entries = beansOfType.entrySet();
//回调生命周期
......@@ -84,6 +87,9 @@ public class ClosingExampleThreadRunHelper extends BaseThreadRunHelper implement
log.info("-------------【开始回调周期{}后置】---------------",entry.getKey());
entry.getValue().postProcessBeforeInitialization(runRecording);
}
});
}
});
return UNIVERSAL_WAIT_TIME;
......
......@@ -70,6 +70,6 @@ public class ThreadPoolUtil {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("[byit-myth-job]-"+threadName+"-Thread-%d").build();
return new ThreadPoolExecutor(coreCount, maxCount,
keepAliveTime, timeUnit,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
new LinkedBlockingQueue<Runnable>(queueLength), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment