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

自助建站优化如何开发属于自己的小程序

自助建站优化,如何开发属于自己的小程序,网站开发的著作权归谁,手机端怎样做网站建设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.hkea.cn/news/14433844/

相关文章:

  • 网站备案vpn注销成都市网站公司
  • 新加坡的网站域名福清营销型网站建设方案
  • 上传空间网站站长工具ip地址查询域名
  • 空间设计工作室网站商城开发平台
  • 网站建设成本报表wordpress theme 修改
  • 芜湖网站建设费用小红书seo是什么意思
  • 网站和微信订阅号优势35互联做网站多少钱
  • 包头企业微网站开发ppt模板免费下载网站有哪些
  • 手机网站客户端360建筑网质量怎么样
  • 免费发广告的网站wordpress调用爱奇艺
  • 设计一个学院网站表情包制作生成器
  • 建网站地址wordpress速卖通插件
  • 登烈建站hp网站
  • 建设网站制opencart wordpress
  • 安阳网站开发网站建设考试重点
  • 巴中微网站建设网站开发文档撰写
  • 体育网站建设方案北京广告设计公司
  • 网站建设公司正规吗文化投资的微网站怎么做
  • wordpress软件站主题莱芜网站优化方案
  • 网站建设的目入图片新能源电动汽车电池使用寿命多久
  • 建行网站会员是什么自己做电视视频网站吗
  • 网站建设服务费记账分录电商平台网站有哪些
  • 网站建设技术架构怎样下载wordpress
  • 江西旅游网站建设方案wordpress更换域名缩略图不显示
  • 个人购物网站搭建我需要把网站做
  • 佛山网站维护英铭长沙网站建设
  • 济南网站建设内容信息化网站建设引言
  • 无锡装饰网站建设排名网站代码上传后无法打开
  • 做设计的公司的网站南通专业做网站
  • 孝感 网站建设好的网站设计培训机构