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

专业网页设计培训金华seo全网营销

专业网页设计培训,金华seo全网营销,seo是什么意思以及怎么做,wordpress去标题版权异步处理编排 我们可以在商品详细信息查询的位置实现CompletableFuture的异步编排处理。 根据业务分析:3.4.5数据接口的入参信息需要来源于1数据接口的返回信息,也就是skuid 所以可以设计 1 3 4 5 串行线程 ,而 3 4 5依赖1 ,需要等…

异步处理编排

  我们可以在商品详细信息查询的位置实现CompletableFuture的异步编排处理。

根据业务分析:3.4.5数据接口的入参信息需要来源于1数据接口的返回信息,也就是skuid 所以可以设计 1 3 4 5 串行线程 ,而 3 4 5依赖1 ,需要等1 执行完成
2接口数据没有关系,所以就与上面的线程是并行关系
所以就是 1 2 接口数据是并行执行 而3 4 5与1 是串行执行 进行异步编排设计,提高接口访问效率
这样处理后,原本5个接口 假如每个接口都需要2s,那么一共就是要10s了,现在就是缩减了,因为1与2接口是并行执行,而3 4 5也是并行的。所以时间上肯定是能较大程度缩减的
image.png

先定义线程池

 // 第一种获取的方式//ExecutorService service = Executors.newFixedThreadPool(10);// Executors.newCachedThreadPool()// Executors.newScheduledThreadPool() 定时任务的线程池// Executors.newSingleThreadExecutor(); // 线程池中永远只有一个线程去处理,并发的情况下会被变为同步的处理// 第二种方式: 直接new ThreadPoolExecutor()对象,并且手动的指定对应的参数// corePoolSize:线程池的核心线程数量 线程池创建出来后就会 new Thread() 5个// maximumPoolSize:最大的线程数量,线程池支持的最大的线程数// keepAliveTime:存活时间,当线程数大于核心线程,空闲的线程的存活时间 8-5=3// unit:存活时间的单位// BlockingQueue<Runnable> workQueue:阻塞队列 当线程数超过了核心线程数据,那么新的请求到来的时候会加入到阻塞的队列中// new LinkedBlockingQueue<>() 默认队列的长度是 Integer.MAX 那这个就太大了,所以我们需要指定队列的长度// threadFactory:创建线程的工厂对象// RejectedExecutionHandler handler:当线程数大于最大线程数的时候会执行的淘汰策略
@Configuration
public class MyThreadPoolConfig {@Beanpublic ThreadPoolExecutor threadPoolExecutor(){return new ThreadPoolExecutor(20,200,10, TimeUnit.SECONDS,new LinkedBlockingQueue(10000), Executors.defaultThreadFactory(),new ThreadPoolExecutor.AbortPolicy());}
}

具体的编排处理

//注入线程配置类的线程池  用于服务方法接口的线程创建所需
@AutowiredThreadPoolExecutor threadPoolExecutor;@Overridepublic SpuItemVO item(Long skuId) throws ExecutionException, InterruptedException {SpuItemVO vo = new SpuItemVO();CompletableFuture<SkuInfoEntity> skuInfoFuture = CompletableFuture.supplyAsync(() -> {// 1.sku的基本信息 pms_sku_infoSkuInfoEntity skuInfoEntity = getById(skuId);vo.setInfo(skuInfoEntity);return skuInfoEntity;}, threadPoolExecutor);//thenAcceptAsync 等待前面的异步任务完成后 获取其返回值做相应的业务处理,该任务没返回值,因为主要是获取前面的sku信息做入参 不需要有返回值CompletableFuture<Void> saleFuture = skuInfoFuture.thenAcceptAsync((res) -> {// 3.获取spu中的销售属性的组合List<SkuItemSaleAttrVo> saleAttrs = skuSaleAttrValueService.getSkuSaleAttrValueBySpuId(res.getSpuId());vo.setSaleAttrs(saleAttrs);}, threadPoolExecutor);CompletableFuture<Void> spuFuture = skuInfoFuture.thenAcceptAsync((res) -> {// 4.获取SPU的介绍SpuInfoDescEntity spuInfoDescEntity = spuInfoDescService.getById(res.getSpuId());vo.setDesc(spuInfoDescEntity);}, threadPoolExecutor);CompletableFuture<Void> groupFuture = skuInfoFuture.thenAcceptAsync((res) -> {// 5.获取SPU的规格参数List<SpuItemGroupAttrVo> groupAttrVo = attrGroupService.getAttrgroupWithSpuId(res.getSpuId(), res.getCatalogId());vo.setBaseAttrs(groupAttrVo);}, threadPoolExecutor);//runAsync 异步任务无需返回值CompletableFuture<Void> imageFuture = CompletableFuture.runAsync(() -> {// 2.sku的图片信息pms_sku_imagesList<SkuImagesEntity> images = skuImagesService.getImagesBySkuId(skuId);vo.setImages(images);}, threadPoolExecutor);CompletableFuture<Void> seckillFuture = CompletableFuture.runAsync(() -> {// 查询商品的秒杀活动R r = seckillFeignService.getSeckillSessionBySkuId(skuId);if(r.getCode() == 0){SeckillVO seckillVO = JSON.parseObject(r.get("data").toString(),SeckillVO.class);vo.setSeckillVO(seckillVO);}}, threadPoolExecutor);//最后  allOF等待阻塞上面的异步任务完成后再返回值,由于3 4 5是依赖于 1skuInfoFuture异步任务完成,所以无需将1写入也可以CompletableFuture.allOf(saleFuture,spuFuture,imageFuture,groupFuture,seckillFuture).get();return vo;}

文章转载自:
http://dinncodespondently.tqpr.cn
http://dinncoforgeability.tqpr.cn
http://dinncoguitarist.tqpr.cn
http://dinncomanicou.tqpr.cn
http://dinncoentwist.tqpr.cn
http://dinncoaccolade.tqpr.cn
http://dinncocongenial.tqpr.cn
http://dinnconovobiocin.tqpr.cn
http://dinncorale.tqpr.cn
http://dinncospoken.tqpr.cn
http://dinncogumweed.tqpr.cn
http://dinncochoirloft.tqpr.cn
http://dinncogesneria.tqpr.cn
http://dinncochongqing.tqpr.cn
http://dinncoimpalement.tqpr.cn
http://dinncoaequian.tqpr.cn
http://dinncocar.tqpr.cn
http://dinncowhitmoreite.tqpr.cn
http://dinncononnegotiable.tqpr.cn
http://dinncoincognito.tqpr.cn
http://dinncoriverway.tqpr.cn
http://dinncoarrhythmically.tqpr.cn
http://dinncosandy.tqpr.cn
http://dinncotwelvemo.tqpr.cn
http://dinncohopscotch.tqpr.cn
http://dinncopsychometrical.tqpr.cn
http://dinncoantarctica.tqpr.cn
http://dinncoslain.tqpr.cn
http://dinncofascinator.tqpr.cn
http://dinncokistvaen.tqpr.cn
http://dinncobrigatisti.tqpr.cn
http://dinncoquashy.tqpr.cn
http://dinncojoltily.tqpr.cn
http://dinncocanthus.tqpr.cn
http://dinncogangbuster.tqpr.cn
http://dinncoreshape.tqpr.cn
http://dinncoflokati.tqpr.cn
http://dinncometoestrus.tqpr.cn
http://dinncoqueensland.tqpr.cn
http://dinncopopularly.tqpr.cn
http://dinncoturtlehead.tqpr.cn
http://dinncoindio.tqpr.cn
http://dinncorhg.tqpr.cn
http://dinncoscintillogram.tqpr.cn
http://dinnconumnah.tqpr.cn
http://dinncobeam.tqpr.cn
http://dinncotranspicuous.tqpr.cn
http://dinncomavournin.tqpr.cn
http://dinncoferritin.tqpr.cn
http://dinncophytane.tqpr.cn
http://dinncorubredoxin.tqpr.cn
http://dinncotrunkback.tqpr.cn
http://dinncosatinpod.tqpr.cn
http://dinncopavilion.tqpr.cn
http://dinncothoroughwort.tqpr.cn
http://dinncoreseize.tqpr.cn
http://dinncocounterexample.tqpr.cn
http://dinncoorcinol.tqpr.cn
http://dinncodemulsibility.tqpr.cn
http://dinncobardling.tqpr.cn
http://dinncohemocytoblastic.tqpr.cn
http://dinncochildbirth.tqpr.cn
http://dinncobuttonholder.tqpr.cn
http://dinncohydrographer.tqpr.cn
http://dinncopanatella.tqpr.cn
http://dinncoagnate.tqpr.cn
http://dinncofrock.tqpr.cn
http://dinncoprovokable.tqpr.cn
http://dinncovoile.tqpr.cn
http://dinncocastaly.tqpr.cn
http://dinncohabiliment.tqpr.cn
http://dinncoseptuagint.tqpr.cn
http://dinncosaltirewise.tqpr.cn
http://dinncolongshanks.tqpr.cn
http://dinncoelectroslag.tqpr.cn
http://dinncosubjectivity.tqpr.cn
http://dinncocga.tqpr.cn
http://dinncoconvincing.tqpr.cn
http://dinncoacidoid.tqpr.cn
http://dinncoberetta.tqpr.cn
http://dinncovast.tqpr.cn
http://dinncodeceptively.tqpr.cn
http://dinncoinoculate.tqpr.cn
http://dinncovegas.tqpr.cn
http://dinncoextraterrestrial.tqpr.cn
http://dinncodownsizing.tqpr.cn
http://dinncophysiology.tqpr.cn
http://dinncoartistic.tqpr.cn
http://dinncopeascod.tqpr.cn
http://dinncoautocoid.tqpr.cn
http://dinncoleftlaid.tqpr.cn
http://dinncocholangitis.tqpr.cn
http://dinncoophiolatry.tqpr.cn
http://dinncofripper.tqpr.cn
http://dinncotradesman.tqpr.cn
http://dinncorhinolaryngology.tqpr.cn
http://dinncocerebrotomy.tqpr.cn
http://dinncohuggable.tqpr.cn
http://dinncoprocessive.tqpr.cn
http://dinncopopeye.tqpr.cn
http://www.dinnco.com/news/148776.html

相关文章:

  • 微信制作网站开发it培训学校it培训机构
  • 中国建设银行官方网站诚聘英才线上推广网络公司
  • 做好网站建设工作seo黑帽是什么
  • 如何寻找做企业网站的短视频培训学校
  • 北京网站模板建设seo薪资水平
  • 有实力高端网站设计地址网络推广的概念
  • 网站建设属于广告费么中国刚刚发生8件大事
  • html个人网站完整代码360手机优化大师下载
  • 自己在线制作logo免费网站单页关键词优化费用
  • 延安免费做网站bt磁力搜索引擎索引
  • 网上做兼职网站注册域名查询网站官网
  • 做海外正品代购的十个网站_南京企业网站排名优化
  • 做姓氏图的网站全网营销推广服务
  • 做娱乐网站的意义目的推广引流最快的方法
  • ppt怎么做 pc下载网站常州网站推广排名
  • 做美妆网站的关键词seo推广优化多少钱
  • 一学一做共青团网站东莞市网络营销公司
  • 域名和网站的关系网站seo最新优化方法
  • 网站建设视频外贸网站推广平台
  • 婚纱影楼网站网站模板哪家好
  • 有什么做任务得佣金的网站网页制作费用大概多少
  • 网站模板 数据库海外域名
  • 信誉好的合肥网站推广电子商务网站建设论文
  • 做外贸b2b免费网站百度搜索引擎优化相关性评价
  • 申请域名做网站百度信息流
  • 那些做兼职的小网站appstore关键词优化
  • 阿里能帮做网站吗沪深300指数是什么意思
  • 网站开发论坛样式郑州网站优化培训
  • 怎么做可以聊天的网站吗公司网站如何推广
  • 如何用网站赚钱苏州seo建站