TASK:模块化;
This commit is contained in:
@@ -328,7 +328,7 @@ public class GenerateConsumer {
|
|||||||
log.info("toProductImageBatch response : {}", generateResult);
|
log.info("toProductImageBatch response : {}", generateResult);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
log.info("tasks_id : {} start ", generateResult.get("task_id"));
|
||||||
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
if (!StringUtils.isEmpty(generateResult.getString("progress"))) {
|
||||||
String progress = generateResult.getString("progress");
|
String progress = generateResult.getString("progress");
|
||||||
JSONArray result = generateResult.getJSONArray("result");
|
JSONArray result = generateResult.getJSONArray("result");
|
||||||
@@ -336,15 +336,15 @@ public class GenerateConsumer {
|
|||||||
if (!StringUtils.isEmpty(result)) {
|
if (!StringUtils.isEmpty(result)) {
|
||||||
url = result.getString(0);
|
url = result.getString(0);
|
||||||
}
|
}
|
||||||
String taskId = generateResult.getString("tasks_id");
|
String taskId = generateResult.getString("task_id");
|
||||||
userLikeGroupService.toProductBatch(taskId, url, progress);
|
userLikeGroupService.toProductBatch(taskId, url, progress);
|
||||||
} else {
|
} else {
|
||||||
// 修改redis中的数据状态为exception
|
// 修改redis中的数据状态为exception
|
||||||
String key = toProductImageResultKey + ":" + generateResult.get("tasks_id");
|
String key = toProductImageResultKey + ":" + generateResult.get("task_id");
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("task_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
// 将异常信息存到exception中
|
// 将异常信息存到exception中
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(generateResult.getString("tasks_id"), generateResult.getString("data"));
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("data"));
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ public class GenerateConsumer {
|
|||||||
try {
|
try {
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("tasks_id"));
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
}
|
}
|
||||||
@@ -361,13 +361,13 @@ public class GenerateConsumer {
|
|||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
" Exception message : " + e.getMessage();
|
" Exception message : " + e.getMessage();
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
exceptionInfo.put(String.valueOf(generateResult.get("task_id")), exceptionMessage);
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("task_id"), generateResult.get("message"), (end - start));
|
||||||
log.info("============ProcessToProductImageBatchResult End listening==========");
|
log.info("============ProcessToProductImageBatchResult End listening==========");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,19 +379,19 @@ public class GenerateConsumer {
|
|||||||
log.info("relightBatch response : {}", generateResult);
|
log.info("relightBatch response : {}", generateResult);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("tasks_id : {} start ", generateResult.get("tasks_id"));
|
log.info("task_id : {} start ", generateResult.get("task_id"));
|
||||||
if (generateResult.get("status").equals("SUCCESS")) {
|
if (generateResult.get("status").equals("SUCCESS")) {
|
||||||
String progress = generateResult.getString("progress");
|
String progress = generateResult.getString("progress");
|
||||||
String url = generateResult.getJSONArray("result").getString(0);
|
String url = generateResult.getJSONArray("result").getString(0);
|
||||||
String taskId = generateResult.getString("tasks_id");
|
String taskId = generateResult.getString("task_id");
|
||||||
userLikeGroupService.relightBatch(taskId, url, progress);
|
userLikeGroupService.relightBatch(taskId, url, progress);
|
||||||
} else {
|
} else {
|
||||||
// 修改redis中的数据状态为exception
|
// 修改redis中的数据状态为exception
|
||||||
String key = relightResultKey + ":" + generateResult.get("tasks_id");
|
String key = relightResultKey + ":" + generateResult.get("task_id");
|
||||||
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("tasks_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
redisUtil.addToString(key, new Gson().toJson(new GenerateResultVO(generateResult.getString("task_id"), null, null, "Fail")), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
// 将异常信息存到exception中
|
// 将异常信息存到exception中
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(generateResult.getString("tasks_id"), generateResult.getString("data"));
|
exceptionInfo.put(generateResult.getString("task_id"), generateResult.getString("data"));
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
@@ -400,7 +400,7 @@ public class GenerateConsumer {
|
|||||||
try {
|
try {
|
||||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||||
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
// 将消息从redis排队队列中删除,需保证被消费的消息存储到db之后再从redis删除
|
||||||
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("tasks_id"));
|
redisUtil.removeFromZSet(consumptionOrderKey, generateResult.getString("task_id"));
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
log.error("手动确认,取消返回队列,不再重新消费");
|
log.error("手动确认,取消返回队列,不再重新消费");
|
||||||
}
|
}
|
||||||
@@ -408,13 +408,13 @@ public class GenerateConsumer {
|
|||||||
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
String exceptionMessage = JSONObject.toJSONString(generateResult) +
|
||||||
" Exception message : " + e.getMessage();
|
" Exception message : " + e.getMessage();
|
||||||
HashMap<String, String> exceptionInfo = new HashMap<>();
|
HashMap<String, String> exceptionInfo = new HashMap<>();
|
||||||
exceptionInfo.put(String.valueOf(generateResult.get("tasks_id")), exceptionMessage);
|
exceptionInfo.put(String.valueOf(generateResult.get("task_id")), exceptionMessage);
|
||||||
// 存redis
|
// 存redis
|
||||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
log.info("tasks_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("tasks_id"), generateResult.get("message"), (end - start));
|
log.info("task_id : {}, end , message : {}, 执行时长: {} 毫秒", generateResult.get("task_id"), generateResult.get("message"), (end - start));
|
||||||
log.info("============ProcessRelightBatchResult End listening==========");
|
log.info("============ProcessRelightBatchResult End listening==========");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,15 +500,15 @@ public class GenerateConsumer {
|
|||||||
public void getDesignBatchResult(Message msg, Channel channel) {
|
public void getDesignBatchResult(Message msg, Channel channel) {
|
||||||
processDesignBatchResult(msg, channel);
|
processDesignBatchResult(msg, channel);
|
||||||
}
|
}
|
||||||
// @RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageBatch}")
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.toProductImageBatch}")
|
||||||
// @RabbitHandler
|
@RabbitHandler
|
||||||
// public void getToProductImageBatchResult(Message msg, Channel channel) {
|
public void getToProductImageBatchResult(Message msg, Channel channel) {
|
||||||
// processToProductImageBatchResult(msg, channel);
|
processToProductImageBatchResult(msg, channel);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @RabbitListener(queues = "#{rabbitMQProperties.queues.relightBatch}")
|
@RabbitListener(queues = "#{rabbitMQProperties.queues.relightBatch}")
|
||||||
// @RabbitHandler
|
@RabbitHandler
|
||||||
// public void getRelightBatchResult(Message msg, Channel channel) {
|
public void getRelightBatchResult(Message msg, Channel channel) {
|
||||||
// processRelightBatchResult(msg, channel);
|
processRelightBatchResult(msg, channel);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user