当前位置: 首页 > news >正文

网站建设方案维护网站建设 浏览器兼容

网站建设方案维护,网站建设 浏览器兼容,兼职做任务的网站,自动seo优化SpringBoot异步任务#xff08;2#xff09;|#xff08;线程池使用#xff09; 文章目录 SpringBoot异步任务#xff08;2#xff09;|#xff08;线程池使用#xff09;[TOC] 前言一、使用场景二、springboot添加异步任务1.配置线程池2.线程池的使用 总结 章节 第一章…SpringBoot异步任务2|线程池使用 文章目录 SpringBoot异步任务2|线程池使用[TOC] 前言一、使用场景二、springboot添加异步任务1.配置线程池2.线程池的使用 总结 章节 第一章链接: SpringBoot异步任务1|异步任务执行以及回调 前言 线程池开启异步任务在springboot中的使用 一、使用场景 项目中有一个批量调度的任务客户上传批量的文章让后将这些文章去进行任务处理 二、springboot添加异步任务 1.配置线程池 在springboot容器中配置线程池后续使用直接将bean注入使用即可 Configuration EnableAsync public class ExecutorEmbPoolConfig {private static final Logger logger LoggerFactory.getLogger(ExecutorEmbPoolConfig.class);Value(${embedding.pool.corePoolSize:20})private int corePoolSize 20;Value(${embedding.pool.maxPoolSize:20})private int maxPoolSize 20;Value(${embedding.pool.queueCapacity:100000})private int queueCapacity 100000;private String namePrefix embedding-service-;Bean(name embeddingServiceExecutor)public ThreadPoolTaskExecutor asyncServiceExecutor() {logger.debug(start embedding embeddingServiceExecutor);ThreadPoolTaskExecutor executor new ThreadPoolTaskExecutor();//配置核心线程数executor.setCorePoolSize(corePoolSize);//配置最大线程数executor.setMaxPoolSize(maxPoolSize);//配置队列大小executor.setQueueCapacity(queueCapacity);//配置线程池中的线程的名称前缀executor.setThreadNamePrefix(namePrefix);// 允许回收核心线程executor.setAllowCoreThreadTimeOut(true);// CALLER_RUNS: 不在新线程中执行任务而是有调用者所在的线程来执行executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());//执行初始化executor.initialize();return executor;} }2.线程池的使用 Resource(name embeddingServiceExecutor)private ThreadPoolTaskExecutor executor;Scheduled(cron 0/30 * * * * ?)public void FileToMilvesJob() {//定义计数器ListDocumentMilvusRecord documentMilvusRecords recordService.findByStatus(RecordStatus.WAIT);if (CollectionUtils.isEmpty(documentMilvusRecords)) {return;}ListDocumentMilvusRecord excuteList;if (documentMilvusRecords.size() 50) {excuteList documentMilvusRecords.subList(0, 50);} else {excuteList documentMilvusRecords;}log.info(本次任务需要执行任务“{}条, excuteList.size());for (DocumentMilvusRecord record : excuteList) {recordService.updateRecordStatus(record);executor.execute(() - {try {docEmbeddingCreate(record); // 执行业务逻辑} catch (Exception e) {log.error(e.getMessage());}});}} 总结 上面的方式实现了自定义一个线程池然后执行任务的时候获取线程池并执行任务。
http://www.dnsts.com.cn/news/196994.html

相关文章:

  • 做网站页面设计报价wordpress扁平化博客主题
  • 自己怎么做百度网站h5游戏搭建
  • 空包网站分站怎么做html个人网页完整代码展示
  • 做电影平台网站怎么赚钱吗郑州发布最新消息今天
  • 国外做名片的网站手机怎样建网站
  • 如何建英文网站网页版word编辑器
  • 珠海 旅游 网站建设网页视频下载快捷指令
  • 外包建站公司网站美工培训学校
  • 阳泉住房和城乡建设厅网站wordpress 评论 折叠
  • 网站建设优化培训班网页加载不出来怎么办
  • 贵阳手机网站建设费用网站设计好以后怎么上线
  • 德宏做网站qq电脑版网页登录入口
  • 网站关键词排行查询网页设计师面试
  • 网站建设维护报价泉州seo
  • 向网站上传文件怎么做素材免费网站
  • 购物网站代码html如何完整建设一个网站
  • 手机网站焦点图代码wordpress+网站白屏
  • 做环评需要关注哪些网站手机端网页设计尺寸规范
  • wampserver搭建网站WordPress文章图片采集插件
  • 石家庄哪里有做网站的长沙做四维彩超玛丽亚m网站
  • 可以免费建立网站吗wordpress破解汉化版
  • 什么叫定制网站网站建设工程师是做什么的
  • 网站转备案长春制作网站定制
  • 请写出网站建设的整个过程做公益活动的网站
  • 网站二维码悬浮台州自助建站公司
  • 文化传播公司网站模板wordpress 判断是否为首页
  • 淘宝客网站如何做网站设计公司营销crm系统
  • 网站一般字体成都网站建设开
  • 官方网站建设维护合作协议五里坨网站建设
  • 外贸网站建设软件有哪些wordpress 注册用户 邮件