|
@@ -11,7 +11,8 @@ public class AgentSender extends Thread{ |
|
@@ -11,7 +11,8 @@ public class AgentSender extends Thread{ |
11
|
|
11
|
|
12
|
private static final Logger logger = Logger.getLogger(AgentSender.class);
|
12
|
private static final Logger logger = Logger.getLogger(AgentSender.class);
|
13
|
|
13
|
|
14
|
- public volatile boolean bool = false;
|
14
|
+ public static boolean isrunning;
|
|
|
15
|
+
|
15
|
Jedis jedis = new Jedis("10.50.3.73", 6379);
|
16
|
Jedis jedis = new Jedis("10.50.3.73", 6379);
|
16
|
|
17
|
|
17
|
private IMFClient client;
|
18
|
private IMFClient client;
|
|
@@ -24,47 +25,77 @@ public class AgentSender extends Thread{ |
|
@@ -24,47 +25,77 @@ public class AgentSender extends Thread{ |
24
|
public void run(){
|
25
|
public void run(){
|
25
|
logger.info(jedis);
|
26
|
logger.info(jedis);
|
26
|
|
27
|
|
27
|
- while(!bool){
|
28
|
+ try {
|
|
|
29
|
+
|
|
|
30
|
+ if (this.client == null) {
|
|
|
31
|
+ logger.info("IMFClient has been closed");
|
|
|
32
|
+ return;
|
|
|
33
|
+ }
|
|
|
34
|
+ isrunning=true;
|
28
|
if(Main.isSuc){
|
35
|
if(Main.isSuc){
|
|
|
36
|
+ logger.info("《《《主线程初始化成功。。。。》》》");
|
29
|
if(Main.LOGIN_OK){
|
37
|
if(Main.LOGIN_OK){
|
30
|
- String SendMsg = jedis.rpoplpush("task-queue", "tmp-queue"); //取队列消息
|
|
|
31
|
-
|
|
|
32
|
- //队列消息不为NULL开始发送
|
|
|
33
|
- if(SendMsg !=null && SendMsg.length() != 0){
|
|
|
34
|
- logger.info("《《《已读取队列消息,请关注下方发送信息LOG回显》》》");
|
|
|
35
|
- try{
|
|
|
36
|
- String returnMsg = client.sendMSG(SendMsg);
|
|
|
37
|
- logger.debug("<<发送返回的信息:"+returnMsg+">>");
|
|
|
38
|
-
|
|
|
39
|
- //9是发送成功
|
|
|
40
|
- if(returnMsg.indexOf("<CODE>9</CODE>")>=0){
|
|
|
41
|
- jedis.rpop("tmp-queue");
|
|
|
42
|
- logger.debug("<<移除队列>>");
|
|
|
43
|
- }else{
|
|
|
44
|
- //如果发送不成功继续发送
|
|
|
45
|
- jedis.rpoplpush("tmp-queue", "task-queue");
|
|
|
46
|
- logger.info("!!<<执行未成功发送的消息返回到发送消息队列>>!!");
|
|
|
47
|
- }
|
|
|
48
|
- }catch (Exception e){
|
|
|
49
|
- e.printStackTrace();
|
|
|
50
|
- logger.info("!!<<请注意!发送异常====>>!!");
|
38
|
+ logger.info("《《《登录成功开始轮询500mm一次。。。。》》》");
|
|
|
39
|
+ while(true){
|
|
|
40
|
+ String SendMsg = jedis.rpoplpush("task-queue", "tmp-queue"); //取队列消息
|
|
|
41
|
+ //队列消息不为NULL开始发送
|
|
|
42
|
+ if(SendMsg !=null && SendMsg.length() != 0){
|
|
|
43
|
+
|
|
|
44
|
+ String returnMsg = this.client.sendMSG(SendMsg);
|
|
|
45
|
+ logger.debug("<<发送返回的信息:"+returnMsg+">>");
|
|
|
46
|
+
|
|
|
47
|
+ //9是发送成功
|
|
|
48
|
+ if(returnMsg.indexOf("<CODE>9</CODE>")>=0){
|
|
|
49
|
+ try {
|
|
|
50
|
+ jedis.rpop("tmp-queue");
|
|
|
51
|
+ logger.debug("<<移除队列>>");
|
|
|
52
|
+ } catch (Exception e) {
|
|
|
53
|
+ e.printStackTrace();
|
|
|
54
|
+ logger.info(e.getMessage());
|
|
|
55
|
+ logger.info("!!移除队列失败!!");
|
|
|
56
|
+ }
|
|
|
57
|
+
|
|
|
58
|
+
|
|
|
59
|
+ }else{
|
|
|
60
|
+ //如果发送不成功继续发送
|
|
|
61
|
+ try{
|
|
|
62
|
+ jedis.rpoplpush("tmp-queue", "task-queue");
|
|
|
63
|
+ logger.info("!!<<执行未成功发送的消息返回到发送消息队列>>!!");
|
|
|
64
|
+ }catch (Exception e){
|
|
|
65
|
+ e.printStackTrace();
|
|
|
66
|
+ logger.info(e.getMessage());
|
|
|
67
|
+ logger.info("!!回写TMP到TASK队列失败!!");
|
|
|
68
|
+ }
|
|
|
69
|
+
|
|
|
70
|
+
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+
|
51
|
}
|
74
|
}
|
52
|
|
75
|
|
53
|
- }else {
|
|
|
54
|
- logger.info("*********当前队列为空*********");
|
76
|
+ //发送延迟
|
|
|
77
|
+ try {
|
|
|
78
|
+ Thread.sleep(500);
|
|
|
79
|
+ } catch (Exception e) {
|
|
|
80
|
+ e.printStackTrace();
|
|
|
81
|
+ logger.info(e.getMessage());
|
|
|
82
|
+ }
|
55
|
}
|
83
|
}
|
56
|
-
|
|
|
57
|
}else{
|
84
|
}else{
|
58
|
logger.info("---------登陆中");
|
85
|
logger.info("---------登陆中");
|
59
|
}
|
86
|
}
|
60
|
-
|
|
|
61
|
- try {
|
|
|
62
|
- Thread.sleep(500);//发送延迟
|
|
|
63
|
- } catch (Exception e) {
|
|
|
64
|
- e.printStackTrace();
|
|
|
65
|
- }
|
|
|
66
|
}
|
87
|
}
|
|
|
88
|
+
|
|
|
89
|
+ }catch (Exception var14) {
|
|
|
90
|
+ var14.printStackTrace();
|
|
|
91
|
+ logger.info(var14.getMessage());
|
67
|
}
|
92
|
}
|
|
|
93
|
+
|
|
|
94
|
+
|
|
|
95
|
+
|
|
|
96
|
+
|
|
|
97
|
+ isrunning=false;
|
|
|
98
|
+ logger.info("---------线程不在了");
|
68
|
}
|
99
|
}
|
69
|
|
100
|
|
70
|
} |
101
|
} |