3 changed files with 93 additions and 0 deletions
@ -0,0 +1,42 @@
|
||||
package com.logpm.factory.jp.jobhandler; |
||||
|
||||
import com.xxl.job.core.biz.model.ReturnT; |
||||
import com.xxl.job.core.handler.annotation.XxlJob; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.utils.CommonUtil; |
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
@Component |
||||
public class TestJob { |
||||
|
||||
private final RabbitTemplate rabbitTemplate; |
||||
|
||||
@XxlJob("testDelayedQueue") |
||||
public ReturnT<String> testDelayedQueue(String param) { |
||||
log.info("############testDelayedQueue: 测试延迟队列 param={}", param); |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("messageId", CommonUtil.getUUID()); |
||||
map.put("logId", CommonUtil.getUUID()); |
||||
map.put("messageData", "body{[aaaaaaaaaaaaaaaaaaaa]}"); |
||||
map.put("createTime", new Date().getTime()); |
||||
map.put("flagType", "OrderStatusLog"); |
||||
log.info("###############TestData11111111111{}", CommonUtil.dateToStringGeneral(new Date())); |
||||
//将消息携带绑定键值
|
||||
rabbitTemplate.convertAndSend("normal_exchange", "normal_routerkey", map, message->{ |
||||
message.getMessageProperties().setHeader("x-delay",10000); |
||||
return message; |
||||
}); |
||||
|
||||
return ReturnT.SUCCESS; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.logpm.factory.receiver; |
||||
|
||||
import com.rabbitmq.client.Channel; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.common.utils.CommonUtil; |
||||
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 java.util.Date; |
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 异常消息队列 处理器 |
||||
* |
||||
* @author zhy |
||||
*/ |
||||
@Slf4j |
||||
@RabbitListener(queues = "normal_queue") |
||||
@Component |
||||
public class TestDelayedQueueHandler { |
||||
|
||||
|
||||
|
||||
@RabbitHandler |
||||
public void orderStatusHandlerManualAck(Map map, Message message, Channel channel) { |
||||
|
||||
log.info("###############TestData22222222222222{}", CommonUtil.dateToStringGeneral(new Date())); |
||||
|
||||
System.out.println(11111111); |
||||
} |
||||
} |
Loading…
Reference in new issue