| | |
| | | import com.ycl.jxkg.rabbitmq.RabbitMqMsgTypeEnum; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.amqp.core.Message; |
| | | import org.springframework.amqp.core.MessageBuilder; |
| | | import org.springframework.amqp.core.MessageProperties; |
| | | import org.springframework.amqp.rabbit.core.RabbitTemplate; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | |
| | | private final RabbitTemplate rabbitTemplate; |
| | | |
| | | public void examMsg() { |
| | | /** |
| | | * 发送考试消息 |
| | | * |
| | | * @param examId 考试ID |
| | | * @param jsonMsg 消息json |
| | | * @param delayTime 延迟时间,毫秒 |
| | | */ |
| | | public void examMsg(Integer examId, String jsonMsg, Long delayTime) { |
| | | MessageProperties messageProperties = new MessageProperties(); |
| | | messageProperties.setExpiration(delayTime + ""); |
| | | Message message = MessageBuilder.withBody(jsonMsg.getBytes()).andProperties(messageProperties).build(); |
| | | // 设置消息的关联数据,以便发送确认回调、未路由成功消息的处理 |
| | | MyCorrelationData msgCorrelationData = new MyCorrelationData("ddddd", RabbitMqMsgTypeEnum.EXAM); |
| | | rabbitTemplate.convertAndSend("examDlxQueue", (Object) "你好,RabbitMQ", msgCorrelationData); |
| | | MyCorrelationData msgCorrelationData = new MyCorrelationData(examId + "", RabbitMqMsgTypeEnum.EXAM); |
| | | rabbitTemplate.convertAndSend("examExchange", "exam", message, msgCorrelationData); |
| | | } |
| | | |
| | | public void meetMsg() { |