Browse Source

优化邮件发送配置

master
bgy 2 months ago
parent
commit
d3a06d84db
2 changed files with 17 additions and 4 deletions
  1. +15
    -2
      src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java
  2. +2
    -2
      src/main/resources/application.properties

+ 15
- 2
src/main/java/com/topsail/scheduletask/task/CheckRabbitMqScheduleTask.java View File

@ -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);


+ 2
- 2
src/main/resources/application.properties View File

@ -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


Loading…
Cancel
Save