|
|
@ -2,11 +2,13 @@ package com.inspect.analysis.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.Gson; |
|
|
import com.alibaba.nacos.shaded.com.google.gson.Gson; |
|
|
import com.inspect.analysis.constant.AnalyseConstants; |
|
|
import com.inspect.analysis.constant.AnalyseConstants; |
|
|
|
|
|
import com.inspect.base.core.constant.Color; |
|
|
import com.inspect.base.redis.service.RedisService; |
|
|
import com.inspect.base.redis.service.RedisService; |
|
|
import com.inspect.partrolresult.domain.AnalyseRequest; |
|
|
import com.inspect.partrolresult.domain.AnalyseRequest; |
|
|
import com.inspect.partrolresult.service.AnalyseRemoteService; |
|
|
import com.inspect.partrolresult.service.AnalyseRemoteService; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.Logger; |
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
@ -23,13 +25,15 @@ public class AlgorithmRequestProcessConsumer { |
|
|
@Resource |
|
|
@Resource |
|
|
private AnalyseRemoteService analyseRemoteService; |
|
|
private AnalyseRemoteService analyseRemoteService; |
|
|
|
|
|
|
|
|
@Scheduled(fixedDelay = 1000) |
|
|
|
|
|
|
|
|
//@Scheduled(fixedDelay = 1000) |
|
|
|
|
|
@Scheduled(fixedDelayString = "${task.scheduler.request.delay-ms:1000}") |
|
|
public void pollAndProcess() { |
|
|
public void pollAndProcess() { |
|
|
|
|
|
//logger.info(Color.YELLOW + "AlgorithmRequestProcessConsumerTracer" + Color.END); |
|
|
String requestDataInRedis; |
|
|
String requestDataInRedis; |
|
|
RedisTemplate<String, String> redisTemplate = redisService.redisTemplate; |
|
|
RedisTemplate<String, String> redisTemplate = redisService.redisTemplate; |
|
|
while ((requestDataInRedis = redisTemplate.opsForList().leftPop(AnalyseConstants.ALGORITHM_REQUEST_QUEUE)) != null) { |
|
|
while ((requestDataInRedis = redisTemplate.opsForList().leftPop(AnalyseConstants.ALGORITHM_REQUEST_QUEUE)) != null) { |
|
|
try { |
|
|
try { |
|
|
logger.info("AlgorithmProcessConsumer pollAndProcess queueSize: {}, requestData:{}", getQueueSize(), requestDataInRedis); |
|
|
|
|
|
|
|
|
logger.info(Color.CYAN + "AlgorithmRequestProcessConsumerTracer queueSize: {}, requestData: {}" + Color.END, getQueueSize(), requestDataInRedis); |
|
|
AnalyseRequest analyseRequest = new Gson().fromJson(requestDataInRedis, AnalyseRequest.class); |
|
|
AnalyseRequest analyseRequest = new Gson().fromJson(requestDataInRedis, AnalyseRequest.class); |
|
|
analyseRemoteService.sendRequest(analyseRequest, analyseRequest.getTypeList(), analyseRequest.isFilter()); |
|
|
analyseRemoteService.sendRequest(analyseRequest, analyseRequest.getTypeList(), analyseRequest.isFilter()); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
|