mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-24 04:53:50 +08:00
refactor
This commit is contained in:
@@ -6,7 +6,7 @@ package me.chanjar.weixin.common.util;
|
||||
* 微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次
|
||||
* </pre>
|
||||
*/
|
||||
public interface WxMsgIdDuplicateChecker {
|
||||
public interface WxMessageDuplicateChecker {
|
||||
|
||||
/**
|
||||
* 检查消息ID是否重复
|
@@ -10,7 +10,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* 将每个消息id保存在内存里,每隔5秒清理已经过期的消息id,每个消息id的过期时间是15秒
|
||||
* </pre>
|
||||
*/
|
||||
public class WxMsgIdMemoryDuplicateChecker implements WxMsgIdDuplicateChecker {
|
||||
public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChecker {
|
||||
|
||||
/**
|
||||
* 一个消息ID在内存的过期时间:15秒
|
||||
@@ -39,7 +39,7 @@ public class WxMsgIdMemoryDuplicateChecker implements WxMsgIdDuplicateChecker {
|
||||
* 每隔多少周期检查消息ID是否过期:5秒
|
||||
* </pre>
|
||||
*/
|
||||
public WxMsgIdMemoryDuplicateChecker() {
|
||||
public WxMessageInMemoryDuplicateChecker() {
|
||||
this.timeToLive = 15 * 1000l;
|
||||
this.clearPeriod = 5 * 1000l;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class WxMsgIdMemoryDuplicateChecker implements WxMsgIdDuplicateChecker {
|
||||
* @param timeToLive 一个消息ID在内存的过期时间:毫秒
|
||||
* @param clearPeriod 每隔多少周期检查消息ID是否过期:毫秒
|
||||
*/
|
||||
public WxMsgIdMemoryDuplicateChecker(Long timeToLive, Long clearPeriod) {
|
||||
public WxMessageInMemoryDuplicateChecker(Long timeToLive, Long clearPeriod) {
|
||||
this.timeToLive = timeToLive;
|
||||
this.clearPeriod = clearPeriod;
|
||||
}
|
@@ -4,11 +4,11 @@ import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
public class WxMsgIdMemoryDuplicateCheckerTest {
|
||||
public class WxMessageInMemoryDuplicateCheckerTest {
|
||||
|
||||
public void test() throws InterruptedException {
|
||||
Long[] msgIds = new Long[] { 1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l };
|
||||
WxMsgIdMemoryDuplicateChecker checker = new WxMsgIdMemoryDuplicateChecker(2000l, 1000l);
|
||||
WxMessageInMemoryDuplicateChecker checker = new WxMessageInMemoryDuplicateChecker(2000l, 1000l);
|
||||
|
||||
// 第一次检查
|
||||
for (Long msgId : msgIds) {
|
@@ -7,7 +7,7 @@
|
||||
<class name="me.chanjar.weixin.common.bean.WxErrorTest"/>
|
||||
<class name="me.chanjar.weixin.common.bean.WxMenuTest"/>
|
||||
<class name="me.chanjar.weixin.common.util.crypto.WxCryptUtilTest"/>
|
||||
<class name="me.chanjar.weixin.common.util.WxMsgIdMemoryDuplicateCheckerTest"/>
|
||||
<class name="me.chanjar.weixin.common.util.WxMessageInMemoryDuplicateCheckerTest"/>
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
|
Reference in New Issue
Block a user