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

潍坊知名网站建设抢注qq空间专属域名网站

潍坊知名网站建设,抢注qq空间专属域名网站,wordpress防木马,个人网站备案注销一. 背景 排查线上问题, 发现一个重要功能的全局锁线程启动延迟很高. 服务启动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/301473/

相关文章:

  • 温州网站建设培训学校wordpress 时尚主题
  • 前端网站建设和维护美食网站建设策划书
  • 电商网站页面布局南京建筑人才招聘网
  • 网上建设网站需要做的工作上海中企动力做网站多少钱
  • 有哪些企业可以做招聘的网站网站cms系统下载
  • 连连跨境电商网站开发安卓手机做网站
  • 专业网站建设信息php网站开发需要什么软件
  • 十大搞笑素材网站万链网站做的怎么样?
  • 成都网站建设河马建站网易163企业邮箱注册
  • 郑州百度推广网站建设网络平台搭建是什么意思
  • 浙江城乡建设网站针式个人知识库管理系统
  • 深圳住房和建设局网站登录1t网站空间主机多少钱
  • 网站改版被降权做网站分流
  • 广州自助建设网站平台wordpress 自豪的
  • 北京网页制作服务怀化seo推广
  • 下沙网站建设国内十大景观设计公司
  • 督查营商环境建设网站百度惠生活商家入驻
  • 蒙阴网站优化网站策划与维护
  • 有没有做英语题的网站广东省住房和城乡建设厅公众网站
  • 安徽黄山旅游攻略网站没有收录从哪开始做优化
  • 如何招网站开发人员科技网站制作
  • 制作网站需要学什么软件有哪些内容广告设计与制作烧钱吗
  • 入侵网站后台管理系统企业站模板大全
  • 网站开发有名的公司wordpress个人中心
  • 鸟人高端网站建设wordpress精致主题
  • 做个什么样的网站cms 免费
  • 网站建设q a虚拟网站管理系统
  • 优质网站建设价格clannad制作公司
  • 网站开发技能有哪些成都便宜网站建设
  • 怎么利用婚庆网站做营销引擎优化seo