liusheng
2024-08-28 bedd0a1cef215538df64470df6b8d4a022189136
ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
@@ -1,20 +1,24 @@
package com.ruoyi.web.test;
import com.smartor.config.RabbitMqConfig;
import org.junit.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
//@SpringBootTest
//@RunWith(SpringRunner.class)
public class MQTest {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @Test
    public void testSend() {
//        rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, "phone.001", "测试数据001");
//        rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, "phone.002", "测试数据002");
//        rabbitTemplate.convertAndSend(RabbitMqConfig.EXCHANGE_NAME, "phone.003", "测试数据003");
    public void testSend22() {
        LocalTime now = LocalTime.now();
        System.out.println("当前时分: " + now.format(DateTimeFormatter.ofPattern("hh:mm")));
        // 获取下一分钟的时分
        LocalTime nextMinute = now.plusMinutes(1);
        System.out.println("下一分钟的时分: " + nextMinute.format(DateTimeFormatter.ofPattern("hh:mm")));
    }
}