Commit 2def2fbc by huangfusuper

修改redis发布订阅模式的模式 改为redis 数组模式 尾部插入

parent b9f1f019
......@@ -110,7 +110,9 @@ public class ScriptExecutorJobTask implements TimerTask {
}catch (Exception e){
StringRedisTemplate stringRedisTemplate = (StringRedisTemplate) SpringUtil.getBean("stringRedisTemplate");
RunLog runLog = RunLog.builder().isEnd(true).isSuccess(false).runLog("执行资源异常" + e.getMessage()).build();
stringRedisTemplate.convertAndSend("REAL-EXEC-" + mythJobTaskSchedule.getLogId() , JSON.toJSONString(runLog, WriteClassName));
//stringRedisTemplate.convertAndSend("REAL-EXEC-" + mythJobTaskSchedule.getLogId() , JSON.toJSONString(runLog, WriteClassName));
//使用redis 想队尾push一个值
stringRedisTemplate.opsForList().rightPush("REAL-EXEC-" + mythJobTaskSchedule.getLogId() , JSON.toJSONString(runLog, WriteClassName));
log.error("------执行机异常{}-----", e.getMessage());
dispatchResponseDto.setMsg(e.getMessage());
dispatchResponseDto.setCode(JobResultEnum.DISPATCH_FAIL.getCode());
......
......@@ -154,7 +154,9 @@ public class MythJobProcess implements Callable<String>{
this.process.destroy();
}
RunLog runLog = RunLog.builder().isEnd(true).isSuccess(exitCode == 0 ? true : false).build();
stringRedisTemplate.convertAndSend(runKey, JSON.toJSONString(runLog, WriteClassName));
//stringRedisTemplate.convertAndSend(runKey, JSON.toJSONString(runLog, WriteClassName))
//TODO 向队尾追加一个日志
stringRedisTemplate.opsForList().rightPush(runKey , JSON.toJSONString(runLog, WriteClassName));
return outputGobbler.getRecentLog() + "\n" + errorGobbler.getRecentLog();
}
}
......
......@@ -44,7 +44,10 @@ public class LogGobbler extends Thread {
}
this.buffer.append(line + "\n");
runLog.setRunLog(line);
stringRedisTemplate.convertAndSend(runKey, JSON.toJSONString(runLog, WriteClassName));
//stringRedisTemplate.convertAndSend(runKey, JSON.toJSONString(runLog, WriteClassName))
//TODO 向队列队尾插入一个值
stringRedisTemplate.opsForList().rightPush(runKey , JSON.toJSONString(runLog, WriteClassName));
printLog(line);
}
} catch (final IOException e) {
......
......@@ -5,7 +5,6 @@ import com.byit.enums.TransferResultEnum;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment