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

高端建设网站企业5种免费一级域名的申请方法

高端建设网站企业,5种免费一级域名的申请方法,做简历的什么客网站,ip直接访问网站 备案一. 背景 排查线上问题, 发现一个重要功能的全局锁线程启动延迟很高. 服务启动40分钟之后, 才能拿到锁. 排查之后发现原因是因为代码引入了高优先级的ApplicationListener代码, 导致全局锁线程启动延迟. 二. 结论 启动顺序从高到底依次为: ApplicationListener , EventListe…

一. 背景

排查线上问题, 发现一个重要功能的全局锁线程启动延迟很高. 服务启动40分钟之后, 才能拿到锁. 排查之后发现原因是因为代码引入了高优先级的ApplicationListener代码, 导致全局锁线程启动延迟.

二. 结论

启动顺序从高到底依次为: ApplicationListener , @EventListener, CommandLineRunner , 分别可以使用order调整排序.
但是order只能控制同类型间的启动顺序.

三. 伪代码

3.1. 实现ApplicationListener接口

优先级最高,  可以有多个, 同ApplicationListener类型之间, 可以通过@Order(1) 注解控制相同ApplicationListener实现的启动顺序. 

import java.util.concurrent.TimeUnit;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;@Component
@Order(1)
public class ApplicationListener02Test implements ApplicationListener<WebServerInitializedEvent> {@Overridepublic void onApplicationEvent(WebServerInitializedEvent event) {System.out.println("Listener : ApplicationListener02Test");try {TimeUnit.SECONDS.sleep(10);} catch (InterruptedException e) {throw new RuntimeException(e);}}
}

3.2. @EventListener 注解方式

@EventListener 注解方式 优先级是低于 实现ApplicationListener的方式.  必须等实现ApplicationListener类都执行完才启动, 可以通过@Order(1) 注解控制相同@EventListener实现的启动顺序.

import java.util.concurrent.TimeUnit;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;@Component
public class EventListener02Test {@EventListener@Order(0)public void listener(ContextRefreshedEvent event) {System.out.println("Listener : EventListener02Test");try {TimeUnit.SECONDS.sleep(10);} catch (InterruptedException e) {throw new RuntimeException(e);}}}

3.3. 实现CommandLineRunner 方式

优先级最低. 实现CommandLineRunner接口方式 优先级是低于 @EventListener的方式.  必须等实现@EventListener类都执行完才启动, 可以通过@Order(1) 注解控制相同CommandLineRunner实现的启动顺序.
package com.netease.easyflink.monitor.listener;import java.util.concurrent.TimeUnit;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;@Component
@Order(1)
public class CommandLineRunner01Test implements CommandLineRunner {@Overridepublic void run(String... args) throws Exception {System.out.println("Listener : CommandLineRunner01Test");try {TimeUnit.SECONDS.sleep(10);} catch (InterruptedException e) {throw new RuntimeException(e);}}
}
http://www.yayakq.cn/news/711088/

相关文章:

  • 上海的网站设计公司好玩的html代码
  • 如何编写网站建设方案书网站论坛推广方案
  • 推广做网站电话最好的建设工程网站
  • 电子产品的网站建设wordpress宾馆模板
  • 海口建设网站的公司怎么注册集团公司
  • 网页怎么绑定wordpress网站优化策略分析论文
  • 网站开发与设计专业h5必备网站
  • 最好用的网站建设软件wordpress 选择中文
  • 哪个网站可以找设计师做设计《网页设计与网站建设》A卷答案
  • 建筑设计地图网站外包员工
  • 中国版动漫网站模板wordpress协调世界时
  • 好的网站具备的条件wordpress 评论 备份
  • wp网站做404学it要多久多少学费
  • re安装wordpresswordpress怎么做seo关键词
  • 网站搜索引擎推广方案做网站前提需要什么
  • 音乐网站建设视频教程上海一网
  • 59网站一起做网店女鞋联通做网站
  • 学院网站建设进度情况说明wordpress 特效主题
  • 投资担保网站建设网站网页设计前言
  • app下载网站免费锡山区住房和城乡建设局网站
  • 石家庄网站定制制作微信购物商城小程序怎么弄
  • 微网站公司网页制作平台排行榜
  • 沧州网站建设开发服务有哪几个平台做网站
  • 北京给公司做网站多少钱网页设计图片界面
  • 电商网站系统设置网站人数
  • 域名不变 新网站公众号小程序搭建
  • 网站建设完成汇报烟台网站制作工具
  • 自己公司网站自己能做吗北京十大装修公司品牌排行榜
  • ps怎么艺术字字体设计网站一级a做爰片免费网站神马电影
  • 公司建网站软件企业网站的优缺点