spring boot 监听容器启动

时间:2021-05-31 15:01:03
/**
* 在容器启动的时候 加载没问完成的消息重发
* @author zhangyukun
*
*/
@Component
@Slf4j
public class LoadMessageListener implements ApplicationListener<ContextRefreshedEvent>,Ordered { @Autowired
QueueMessageService queueMessageService; @Override
public int getOrder() {
return Integer.MAX_VALUE;
} @Override
public void onApplicationEvent(ContextRefreshedEvent event) {
log.debug("初始化为完成的的消息.................");
queueMessageService.initLoadUnSucceed();
} }