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

四川营销型网站建设天机seo

四川营销型网站建设,天机seo,如何免费做网站推广,旅游公司网页设计一. 背景 排查线上问题, 发现一个重要功能的全局锁线程启动延迟很高. 服务启动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.qdjiajiao.com/news/1112.html

相关文章:

  • 哪个网站可以找人做橱柜网络优化工程师有多累
  • 怎样做娱乐网站百度快照怎么打开
  • asp.net 网站管理工具软件推广是什么工作
  • PHP MYSQL网站开发全程实深圳竞价托管公司
  • 租服务器做网站seo外链论坛
  • 安阳网站建设网络新闻发布平台发稿
  • 在线网站制作工具百度收录技术
  • 优站点网址收录网什么是百度竞价
  • 手机wap网站怎么做网站seo优化教程
  • 官方网站下载方法中国去中心化搜索引擎
  • 西柏坡门户网站建设规划书seo教程培训
  • 延长中路上海网站建设seo网站优化案例
  • 商丘做网站优化上海网络推广公司排名
  • 学校网站的建设需求win7优化配置的方法
  • 日本做蛋糕网站商品标题优化
  • 新网站备案查询百度快速优化软件排名
  • 去了哪找网站建设公司网站推广平台排行
  • 福州网站建设新闻什么是seo优化推广
  • 徐州网站建设的特点自己创建个人免费网站
  • wordpress快速建站教程日本shopify独立站
  • 长春怎么做网站家庭优化大师免费下载
  • 苹果网站用flash做怎么进行网络营销
  • 网站建设的步骤教程百度指数数据分析平台官网
  • 移动互联网技术优化大师班级
  • 合肥企业网站建设工seo搜索工具栏
  • 网站开发培训什么必应搜索引擎入口官网
  • 前端实战项目11套站长工具seo综合查询引流
  • 做ps找图的网站有哪些培训机构是干什么的
  • 什么网站百度收录快东莞网站建设做网站
  • php动态网站制作流程图热点军事新闻