...
|
...
|
@@ -21,8 +21,6 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
import static com.yoho.tools.common.utils.RandomUtil.getRandom;
|
...
|
...
|
@@ -68,20 +66,18 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
|
|
|
private static final int recPraise = 2;
|
|
|
|
|
|
private static ExecutorService executorService = Executors.newSingleThreadExecutor();
|
|
|
|
|
|
private static final String MESSAGE_KEY = "yh:pfcms:grass:auto_praise:list";
|
|
|
private static final String MESSAGE_SENDING_FLAG = "yh:pfcms:grass:auto_praise:sending";
|
|
|
|
|
|
@PostConstruct
|
|
|
public void startSendMessageTask(){
|
|
|
executorService.execute(() -> {
|
|
|
new Thread(() -> {
|
|
|
while(true){
|
|
|
List<GrassInBoxAddReq> messageList = platformRedis.range(MESSAGE_KEY, "all",
|
|
|
GrassInBoxAddReq.class, 0, -1);
|
|
|
logger.info("startSendMessageTask Begin messageList size is {}",messageList.size());
|
|
|
logger.info("startSendMessageTask Begin messageList size is {}",Objects.isNull(messageList) ? 0 : messageList.size());
|
|
|
|
|
|
if(!messageList.isEmpty()) {
|
|
|
if(CollectionUtils.isNotEmpty(messageList)) {
|
|
|
//在当前线程开始发站内信之前,确保没有别的地方也在跑
|
|
|
//在redis 放一个正在处理的标记位, 正常数据量 2w 30s之内可以处理完, 标记位置有效时间10分钟
|
|
|
Integer sendTime = platformRedis.getValue(MESSAGE_SENDING_FLAG);
|
...
|
...
|
@@ -123,7 +119,7 @@ public class GrassUserVirtualImpl implements IGrassVirtualService{ |
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}).start();
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|