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; package com.byit.service.mapservice.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.byit.conf.RunRecordingThreadPool;
import com.byit.dto.RunRecordingWrapped; import com.byit.dto.RunRecordingWrapped;
import com.byit.enums.EmailEnum; import com.byit.enums.EmailEnum;
import com.byit.enums.FlowPropertyEnum; import com.byit.enums.FlowPropertyEnum;
...@@ -151,13 +152,18 @@ public class RunRecordingAndLogServiceImpl implements RunRecordingAndLogService, ...@@ -151,13 +152,18 @@ public class RunRecordingAndLogServiceImpl implements RunRecordingAndLogService,
runRecordingService.updateRunRecordingById(virtualRunRecording); runRecordingService.updateRunRecordingById(virtualRunRecording);
} }
Map<String, InstanceRunTheLifeCycleCallback> beansOfType = SpringUtil.getBeansOfType(InstanceRunTheLifeCycleCallback.class);
Set<Map.Entry<String, InstanceRunTheLifeCycleCallback>> entries = beansOfType.entrySet(); RunRecordingThreadPool.RUN_RECORDING_THREAD_POOL.submit(() ->{
//回调生命周期 Map<String, InstanceRunTheLifeCycleCallback> beansOfType = SpringUtil.getBeansOfType(InstanceRunTheLifeCycleCallback.class);
for (Map.Entry<String, InstanceRunTheLifeCycleCallback> entry : entries) { Set<Map.Entry<String, InstanceRunTheLifeCycleCallback>> entries = beansOfType.entrySet();
log.info("-------------【开始回调周期{}后置】---------------",entry.getKey()); //回调生命周期
entry.getValue().postProcessBeforeInitialization(runRecording); for (Map.Entry<String, InstanceRunTheLifeCycleCallback> entry : entries) {
} log.info("-------------【开始回调周期{}后置】---------------",entry.getKey());
entry.getValue().postProcessBeforeInitialization(runRecording);
}
});
}); });
......
package com.byit.thread.helper; package com.byit.thread.helper;
import com.byit.conf.RunRecordingThreadPool;
import com.byit.enums.EmailEnum; import com.byit.enums.EmailEnum;
import com.byit.enums.NodeRunStatusPropertyEnum; import com.byit.enums.NodeRunStatusPropertyEnum;
import com.byit.enums.RunRecordingEnum; import com.byit.enums.RunRecordingEnum;
...@@ -77,13 +78,18 @@ public class ClosingExampleThreadRunHelper extends BaseThreadRunHelper implement ...@@ -77,13 +78,18 @@ public class ClosingExampleThreadRunHelper extends BaseThreadRunHelper implement
runRecording.setEndTime(new Date()); runRecording.setEndTime(new Date());
runRecordingService.updateRunRecordingById(runRecording); runRecordingService.updateRunRecordingById(runRecording);
applicationEventPublisher.publishEvent(new EndFlowEvent(this,runRecording)); applicationEventPublisher.publishEvent(new EndFlowEvent(this,runRecording));
Map<String, InstanceRunTheLifeCycleCallback> beansOfType = SpringUtil.getBeansOfType(InstanceRunTheLifeCycleCallback.class);
Set<Map.Entry<String, InstanceRunTheLifeCycleCallback>> entries = beansOfType.entrySet(); RunRecordingThreadPool.RUN_RECORDING_THREAD_POOL.submit(() ->{
//回调生命周期 Map<String, InstanceRunTheLifeCycleCallback> beansOfType = SpringUtil.getBeansOfType(InstanceRunTheLifeCycleCallback.class);
for (Map.Entry<String, InstanceRunTheLifeCycleCallback> entry : entries) { Set<Map.Entry<String, InstanceRunTheLifeCycleCallback>> entries = beansOfType.entrySet();
log.info("-------------【开始回调周期{}后置】---------------",entry.getKey()); //回调生命周期
entry.getValue().postProcessBeforeInitialization(runRecording); for (Map.Entry<String, InstanceRunTheLifeCycleCallback> entry : entries) {
} log.info("-------------【开始回调周期{}后置】---------------",entry.getKey());
entry.getValue().postProcessBeforeInitialization(runRecording);
}
});
} }
}); });
return UNIVERSAL_WAIT_TIME; return UNIVERSAL_WAIT_TIME;
......
...@@ -70,6 +70,6 @@ public class ThreadPoolUtil { ...@@ -70,6 +70,6 @@ public class ThreadPoolUtil {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("[byit-myth-job]-"+threadName+"-Thread-%d").build(); ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("[byit-myth-job]-"+threadName+"-Thread-%d").build();
return new ThreadPoolExecutor(coreCount, maxCount, return new ThreadPoolExecutor(coreCount, maxCount,
keepAliveTime, timeUnit, 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