Springboot--事件监听

 

1 通过SpringApplication发布事件

 

 2 springboot交给 SimpleApplicationEventMulticaster进行处理

  2.1会从缓存中寻找该事件的监听者。其中cachekey是由事件和sourceType确定的类似于这样 "ListenerCacheKey [eventType = org.springframework.boot.context.event.ApplicationReadyEvent, sourceType = class org.springframework.boot.SpringApplication]"

  补充:springboot会在发布事件的时候,遍历所有的listener,然后将监听本事件的listener缓存起来,后面再次发布该事件的时候可以从缓存中取

  

  2.2 将监听该事件的listner缓存起来。

 

3 循环调用监听者相关接口,完成事件通知 

 

 

 学习springboot事件监听源码,如有不对请大家多多指教

 

posted on 2018-11-14 11:44  小成成2016  阅读(118)  评论(0)    收藏  举报

导航