Commit c318f922 by libin

获取返回消息代码优化

parent 95396c8f
...@@ -150,7 +150,13 @@ public class ResourceService { ...@@ -150,7 +150,13 @@ public class ResourceService {
// 循环消费 任务进度 并更新前台界面 // 循环消费 任务进度 并更新前台界面
while (true) { while (true) {
ConsumerRecords<String, String> records = consumer.poll(10000);//消费间隔单位:毫秒 ConsumerRecords<String, String> records = null;//消费间隔单位:毫秒
try {
records = consumer.poll(10000);
} catch (Exception e) {
e.printStackTrace();
}
if(records!=null){
for (ConsumerRecord<String, String> consumerRecord : records) { for (ConsumerRecord<String, String> consumerRecord : records) {
logger.info("消息队列返回内容:{"+consumerRecord.key()+":"+consumerRecord.value()+"}"); // 消息key:taskid的值// 消息value:消息的json字符串 logger.info("消息队列返回内容:{"+consumerRecord.key()+":"+consumerRecord.value()+"}"); // 消息key:taskid的值// 消息value:消息的json字符串
try { try {
...@@ -165,6 +171,9 @@ public class ResourceService { ...@@ -165,6 +171,9 @@ public class ResourceService {
e.printStackTrace(); e.printStackTrace();
} }
} }
}else{
logger.warn("消息队列没有内容返回。");
}
} }
} }
......
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