renxue
2022-10-24 0b055a3f554da3a934e79e88c4781705cbab5a21
提交 | 用户 | age
0b055a 1 package com.hz.canal.starter.listener;
R 2
3 import org.springframework.boot.context.event.ApplicationReadyEvent;
4 import org.springframework.context.ApplicationListener;
5
6 import java.util.concurrent.atomic.AtomicBoolean;
7
8 /**
9  * @author wuqiong 2022/4/16
10  */
11 public class ApplicationReadyListener implements ApplicationListener<ApplicationReadyEvent> {
12
13     public static final AtomicBoolean START_LISTENER_CONTAINER = new AtomicBoolean(false);
14
15     @Override
16     public void onApplicationEvent(ApplicationReadyEvent event) {
17         // 确保程序启动之后,再放行所有的 canal transponder
18         if (!START_LISTENER_CONTAINER.get()) START_LISTENER_CONTAINER.set(true);
19     }
20 }