正在显示
3 个修改的文件
包含
91 行增加
和
6 行删除
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | 5 | ||
6 | package com.airport; | 6 | package com.airport; |
7 | 7 | ||
8 | +import com.airport.core.AgentSender; | ||
8 | import com.airport.core.IMFReader; | 9 | import com.airport.core.IMFReader; |
9 | import com.airport.core.IMFSender; | 10 | import com.airport.core.IMFSender; |
10 | import com.airport.util.ConfigUtils; | 11 | import com.airport.util.ConfigUtils; |
@@ -14,12 +15,15 @@ import com.caac.imf.api.IMFClientFactory; | @@ -14,12 +15,15 @@ import com.caac.imf.api.IMFClientFactory; | ||
14 | import java.util.Timer; | 15 | import java.util.Timer; |
15 | import org.apache.log4j.Logger; | 16 | import org.apache.log4j.Logger; |
16 | import org.apache.log4j.PropertyConfigurator; | 17 | import org.apache.log4j.PropertyConfigurator; |
18 | +import sun.management.Agent; | ||
17 | 19 | ||
18 | public class Main { | 20 | public class Main { |
19 | private static final Logger logger = Logger.getLogger(Main.class); | 21 | private static final Logger logger = Logger.getLogger(Main.class); |
20 | public static boolean LOGIN_OK = false; | 22 | public static boolean LOGIN_OK = false; |
23 | + public static boolean isSuc = true; | ||
21 | public static IMFClient client = null; | 24 | public static IMFClient client = null; |
22 | 25 | ||
26 | + | ||
23 | public Main() { | 27 | public Main() { |
24 | } | 28 | } |
25 | 29 | ||
@@ -40,11 +44,16 @@ public class Main { | @@ -40,11 +44,16 @@ public class Main { | ||
40 | loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties"); | 44 | loginIMF(client, ConfigUtils.IMF_USERNAME, ConfigUtils.IMF_PASSWORD, "config/imf_config.properties"); |
41 | if (LOGIN_OK && client != null) { | 45 | if (LOGIN_OK && client != null) { |
42 | logger.info("start run Timer,client hasocde=" + client.hashCode()); | 46 | logger.info("start run Timer,client hasocde=" + client.hashCode()); |
47 | + | ||
48 | + //代理人发送程序 | ||
49 | +// AgentSender send = new AgentSender(client); | ||
50 | +// send.start(); | ||
51 | + | ||
52 | + //数据仓库给九州的发送程序 | ||
43 | Timer timer = new Timer(); | 53 | Timer timer = new Timer(); |
44 | -// SendMessageTask sender = new SendMessageTask(client, "data/fid_index.txt"); | ||
45 | - IMFSender imfSender = new IMFSender(client,"data/fid_index.txt"); | ||
46 | -// timer.schedule(sender, 30000L, 1200000L); | ||
47 | - timer.schedule(imfSender,30000L,1200000L); | 54 | + IMFSender CangKu2Jiuzhou = new IMFSender(client,"data/fid_index.txt"); |
55 | + timer.schedule(CangKu2Jiuzhou, 30000L, 1200000L); | ||
56 | + | ||
48 | } | 57 | } |
49 | } | 58 | } |
50 | 59 | ||
@@ -83,6 +92,7 @@ public class Main { | @@ -83,6 +92,7 @@ public class Main { | ||
83 | if (!LOGIN_OK) { | 92 | if (!LOGIN_OK) { |
84 | logger.info("多次尝试登录失败,退出登陆"); | 93 | logger.info("多次尝试登录失败,退出登陆"); |
85 | client.disconnect(); | 94 | client.disconnect(); |
95 | + isSuc =false; | ||
86 | System.exit(-1); | 96 | System.exit(-1); |
87 | } | 97 | } |
88 | } | 98 | } |
src/java/com/airport/core/AgentSender.java
0 → 100644
1 | +package com.airport.core; | ||
2 | + | ||
3 | +import com.airport.Main; | ||
4 | +import org.apache.log4j.Logger; | ||
5 | +import com.caac.imf.api.IMFClient; | ||
6 | + | ||
7 | +import redis.clients.jedis.Jedis; | ||
8 | + | ||
9 | +import java.util.Properties; | ||
10 | + | ||
11 | +public class AgentSender extends Thread{ | ||
12 | + | ||
13 | + private static final Logger logger = Logger.getLogger(AgentSender.class); | ||
14 | + private static final String stype = "/MSG/META/STYP"; | ||
15 | + | ||
16 | + public volatile boolean bool = false; | ||
17 | + Jedis jedis = new Jedis("10.50.3.73", 6379); | ||
18 | + // Jedis jedis = new Jedis("192.168.0.253", 6379); | ||
19 | + public String str ; | ||
20 | + | ||
21 | + private IMFClient client; | ||
22 | + | ||
23 | + public AgentSender(IMFClient client){ | ||
24 | + this.client = client; | ||
25 | + } | ||
26 | + | ||
27 | + public AgentSender(){ | ||
28 | + } | ||
29 | + | ||
30 | + public void run(){ | ||
31 | + logger.info(jedis); | ||
32 | + | ||
33 | + while(!bool){ | ||
34 | + if(Main.isSuc){ | ||
35 | + if(Main.LOGIN_OK){ | ||
36 | + String SendMsg = jedis.rpoplpush("task-queue", "tmp-queue"); //取队列消息 | ||
37 | + | ||
38 | + //9是发送成功 | ||
39 | + if(SendMsg !=null){ | ||
40 | + logger.debug("<<发送的报文内容为:"+SendMsg+">>"); | ||
41 | + | ||
42 | + String returnMsg = client.sendMSG(SendMsg); | ||
43 | + logger.debug("<<发送返回的信息:"+returnMsg+">>"); | ||
44 | + | ||
45 | + if(returnMsg.indexOf("<CODE>9</CODE>")>=0){ | ||
46 | + jedis.rpop("tmp-queue"); | ||
47 | + logger.debug("<<移除队列>>"); | ||
48 | + }else{ | ||
49 | + //如果发送不成功继续发送 | ||
50 | + jedis.rpoplpush("tmp-queue", "task-queue"); | ||
51 | + logger.info("!!<<执行未成功发送的消息返回到发送消息队列>>!!"); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + }else{ | ||
56 | + logger.info("---------登陆中"); | ||
57 | + } | ||
58 | + | ||
59 | + try { | ||
60 | + Thread.sleep(5000); | ||
61 | + } catch (Exception e) { | ||
62 | + e.printStackTrace(); | ||
63 | + } | ||
64 | + } | ||
65 | + } | ||
66 | + } | ||
67 | + | ||
68 | + public String getStr() { | ||
69 | + return str; | ||
70 | + } | ||
71 | + | ||
72 | + public void setStr(String str) { | ||
73 | + this.str = str; | ||
74 | + } | ||
75 | +} |
@@ -112,11 +112,11 @@ public class DaoImpl implements Dao { | @@ -112,11 +112,11 @@ public class DaoImpl implements Dao { | ||
112 | } | 112 | } |
113 | 113 | ||
114 | public int getMaxFID() { | 114 | public int getMaxFID() { |
115 | - return this.jdbcTemplate.queryForInt("select max(FID) from MESSAGE_BAK where SNDR='CFPS'"); | 115 | + return this.jdbcTemplate.queryForInt("select max(FID) from MESSAGE_BAK where SNDR='CFPS' OR TYPE='CLR'"); |
116 | } | 116 | } |
117 | 117 | ||
118 | public List<MessageBak> getRecordByFID(int fid) { | 118 | public List<MessageBak> getRecordByFID(int fid) { |
119 | - String SQL_FMT = "select FID,CONTENT from MESSAGE_BAK where (FID>%s and FID<%s+%s) and (SNDR='CFPS') order by FID"; | 119 | + String SQL_FMT = "select FID,CONTENT from MESSAGE_BAK where (FID>%s and FID<%s+%s) and (SNDR='CFPS' OR TYPE='CLR')) order by FID"; |
120 | String sql = String.format(SQL_FMT, fid, fid, ConfigUtils.RECORD_COUNT); | 120 | String sql = String.format(SQL_FMT, fid, fid, ConfigUtils.RECORD_COUNT); |
121 | logger.info(sql); | 121 | logger.info(sql); |
122 | final LobHandler lobHandler = new DefaultLobHandler(); | 122 | final LobHandler lobHandler = new DefaultLobHandler(); |
-
请 注册 或 登录 后发表评论