Commit e2300bd23e331a80b96ace6080c592554da9f6cd
1 parent
9425372fc8
Exists in
master
and in
6 other branches
update code
Showing 2 changed files with 20 additions and 6 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/inteceptor/MybatisSqlInterceptor.java
View file @
e2300bd
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/SendMysqlSyncDatUtil.java
View file @
e2300bd
... | ... | @@ -17,13 +17,15 @@ |
17 | 17 | import java.util.concurrent.TimeUnit; |
18 | 18 | |
19 | 19 | /** |
20 | - * Created by Administrator on 2017-04-25. | |
20 | + * Created by lqy | |
21 | + * on 2017-04-25. | |
21 | 22 | */ |
22 | 23 | @Component |
23 | 24 | public class SendMysqlSyncDatUtil implements InitializingBean { |
24 | 25 | |
25 | 26 | private static BlockingQueue<SqlRequest> syncSqlQueue = new LinkedBlockingQueue(); |
26 | 27 | |
28 | + //配置文件中配置的要同步的区域的url地址 | |
27 | 29 | private static Set<String> urls = new HashSet<>(); |
28 | 30 | static |
29 | 31 | { |
... | ... | @@ -38,6 +40,11 @@ |
38 | 40 | } |
39 | 41 | } |
40 | 42 | |
43 | + /** | |
44 | + * 把要同步的sql添加到阻塞队列中 | |
45 | + * @param sql | |
46 | + * @param sqlId | |
47 | + */ | |
41 | 48 | public static void addSqlToQueue(String sql ,String sqlId) |
42 | 49 | { |
43 | 50 | SqlRequest request = new SqlRequest(); |
44 | 51 | |
45 | 52 | |
46 | 53 | |
... | ... | @@ -46,14 +53,24 @@ |
46 | 53 | syncSqlQueue.add(request); |
47 | 54 | } |
48 | 55 | |
56 | + /** | |
57 | + * 初始化启动发送sql的线程 | |
58 | + * @throws Exception | |
59 | + */ | |
49 | 60 | @Override |
50 | 61 | public void afterPropertiesSet() throws Exception { |
51 | 62 | System.out.println("init ........."); |
52 | - new HandleThread().start(); | |
63 | + Thread thread = new HandleThread(); | |
64 | + thread.setName("syncMysqlThread"); | |
65 | + thread.start(); | |
53 | 66 | } |
54 | 67 | |
55 | 68 | |
69 | + /** | |
70 | + * 从队列中取出一个个取出来发送 | |
71 | + */ | |
56 | 72 | private class HandleThread extends Thread { |
73 | + | |
57 | 74 | @Override |
58 | 75 | public void run() { |
59 | 76 | SqlRequest request = null; |