From d3a06d84db3464eab57e8a08ca166dae9bcde985 Mon Sep 17 00:00:00 2001 From: bgy Date: Thu, 11 Jun 2026 14:24:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=82=AE=E4=BB=B6=E5=8F=91?= =?UTF-8?q?=E9=80=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduletask/task/CheckRabbitMqScheduleTask.java | 17 +++++++++++++++-- src/main/resources/application.properties | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java b/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java index c467780..40de3e4 100644 --- a/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java +++ b/src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java @@ -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 queueMessageCountMap = new HashMap<>(); queueMessageCountMap.put("queue1", 1000L); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 141bb1a..1178f0a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -49,8 +49,8 @@ spring.mail.default-encoding=UTF-8 spring.mail.properties.mail.smtp.ssl.enable=true spring.mail.properties.mail.smtp.socketFactory.port=994 spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory -mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl - +spring.mail.properties.mail.smtp.socketFactory.fallback=false +spring.mail.properties.mail.smtp.ssl.protocols=TLSv1.2 ### 监控配置 ### monitor.service.timeout=30 monitor.mq.max-accumulation=1000