|
|
|
@ -2,6 +2,7 @@ package com.topsail.scheduletask.task; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.topsail.scheduletask.service.AmqpService; |
|
|
|
import com.topsail.scheduletask.util.MaiSenderlUtil; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
@ -18,7 +19,8 @@ import java.util.Map; |
|
|
|
@Configuration //1.主要用于标记配置类,兼备Component的效果。 |
|
|
|
@EnableScheduling // 2.开启定时任务 |
|
|
|
public class CheckRabbitMqScheduleTask { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MaiSenderlUtil maiSenderlUtil; |
|
|
|
@Autowired |
|
|
|
private Environment env; |
|
|
|
@Autowired |
|
|
|
@ -53,7 +55,18 @@ public class CheckRabbitMqScheduleTask { |
|
|
|
amqpService.SendMessage("mailNotice", json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// @Scheduled(cron = "1/60 * * * * ?") |
|
|
|
// //或直接指定时间间隔,例如:5秒 |
|
|
|
//// @Scheduled(fixedRate=5000) |
|
|
|
// private void checkMail() { |
|
|
|
// try { |
|
|
|
// maiSenderlUtil.sendMail("1129801211@qq.com", "测试邮件--主题", "测试邮件--内容", true, null, "测试邮件"); |
|
|
|
// }catch (Exception e){ |
|
|
|
// e.printStackTrace(); |
|
|
|
// System.out.println("发送邮件失败"); |
|
|
|
// System.out.println(e.getMessage()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
public static void main(String[] args) { |
|
|
|
Map<String, Long> queueMessageCountMap = new HashMap<>(); |
|
|
|
queueMessageCountMap.put("queue1", 1000L); |
|
|
|
|