任务过期bug修复

cert
anthonywj 2 years ago
parent a329755408
commit 574f409245

@ -16,10 +16,10 @@ public class TopicRabbitConfig {
public final static String trace = "topic.trace";
public final static String publicer = "topic.all";
public final static String delaytrace = "local.trace.delay";
public final static String delaytrace = "local.trace.delay_me";
public final static String TRACE_TOPIC_EXCHANGE = "trace.topic.exchange";
public final static String TRACE_DELAY_EXCHANGE = "local.trace.delay.exchang";
public final static String TRACE_DELAY_EXCHANGE = "local.trace.delay.exchange";
@Bean

@ -7,6 +7,7 @@ import com.glxp.api.config.rabbit.TopicRabbitConfig;
import com.glxp.api.entity.trace.MqTaskDelayMessage;
import com.glxp.api.entity.trace.MqTraceMessage;
import com.glxp.api.util.DateUtil;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.JsonUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
@ -56,9 +57,9 @@ public class RabbitPushService {
public BaseResponse sendDeleyTask(MqTaskDelayMessage mqTaskDelayMessage, Integer delayTime) {
rabbitTemplate.convertAndSend(TopicRabbitConfig.TRACE_DELAY_EXCHANGE, TopicRabbitConfig.delaytrace, mqTaskDelayMessage, message -> {
rabbitTemplate.convertAndSend(TopicRabbitConfig.TRACE_DELAY_EXCHANGE, "trace.delay.*", mqTaskDelayMessage, message -> {
MessageProperties messageProperties = message.getMessageProperties();
messageProperties.setDelay(delayTime * 1);
messageProperties.setDelay(IntUtil.value(delayTime) * 1000 * 60);
return message;
});
return ResultVOUtils.success("发送成功");

@ -8,13 +8,16 @@ import com.glxp.api.entity.trace.TraceTaskHistoryEntity;
import com.glxp.api.entity.trace.TraceTaskNoticeEntity;
import com.glxp.api.service.trace.TraceTaskHistoryService;
import com.glxp.api.service.trace.TraceTaskNoticeService;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
@Slf4j
@ -34,8 +37,12 @@ public class TraceSearchReceiver {
@Transactional(rollbackFor = Exception.class)
@RabbitListener(queues = TopicRabbitConfig.delaytrace)
public void traceDeleyReceiver(MqTaskDelayMessage mqTaskDelayMessage) {
public void traceDeleyReceiver(MqTaskDelayMessage mqTaskDelayMessage, Channel channel, Message message) {
try {
channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
} catch (IOException e) {
e.printStackTrace();
}
if (mqTaskDelayMessage.getTaskStatus() == 1 || mqTaskDelayMessage.getTaskStatus() == 2) {
log.info(mqTaskDelayMessage.getTaskId() + ":任务超时未处理,更改状态为超时异常");
TraceTaskNoticeEntity taskNoticeEntity = taskNoticeService.getById(mqTaskDelayMessage.getTaskId());

Loading…
Cancel
Save