...
|
...
|
@@ -15,7 +15,9 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
...
|
...
|
@@ -43,7 +45,7 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { |
|
|
private static final int CONTENT_SUB_LENGTH = 250;
|
|
|
|
|
|
|
|
|
public static final String DEFAULT_SENT_LOCK="sent_lock";
|
|
|
public static final String DEFAULT_SENT_LOCK = "sent_lock";
|
|
|
|
|
|
private Map<String, Long> msgSentLogMap = new HashMap<>();
|
|
|
|
...
|
...
|
@@ -179,8 +181,9 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { |
|
|
@Scheduled(fixedRate = 5 * 60 * 1000)
|
|
|
public void clearMsgSentLog() {
|
|
|
|
|
|
synchronized (DEFAULT_SENT_LOCK)
|
|
|
{
|
|
|
synchronized (DEFAULT_SENT_LOCK) {
|
|
|
List<String> clearKeyList = new ArrayList<>();
|
|
|
|
|
|
for (Map.Entry<String, Long> entry : msgSentLogMap.entrySet()) {
|
|
|
|
|
|
String sentKey = entry.getKey();
|
...
|
...
|
@@ -191,9 +194,14 @@ public class AlarmMsgServiceImpl implements AlarmMsgService { |
|
|
|
|
|
if (5 * 60 * 1000 <= (sentAgainTime - sentTime)) {
|
|
|
|
|
|
msgSentLogMap.remove(sentKey);
|
|
|
clearKeyList.add(sentKey);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (String clearKey : clearKeyList) {
|
|
|
|
|
|
msgSentLogMap.remove(clearKey);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|