一、引入依赖
1、pom.xml(ruoyi)
<!--快速集成PowerJob执行器--> <dependency> <groupId>tech.powerjob</groupId> <artifactId>powerjob-worker-spring-boot-starter</artifactId> <version>4.3.1</version> </dependency>
2、pom.xml(ruoyi-admin)
<dependency> <groupId>tech.powerjob</groupId> <artifactId>powerjob-worker-spring-boot-starter</artifactId> </dependency>
3、pom.xml(ruoyi-quartz)
<dependency> <groupId>tech.powerjob</groupId> <artifactId>powerjob-worker-spring-boot-starter</artifactId> </dependency>
二、配置文件修改
#powerjob配置 powerjob: worker: app-name: rouyi akka-port: 27777 server-address: 192.168.56.12:7700 protocol: http store-strategy: disk max-result-length: 4096 max-appended-wf-context-length: 4096 max-lightweight-task-num: 1024 max-heavy-task-num: 64
三、powerJob注册应用
四、代码
package com.ruoyi.quartz.processors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.stereotype.Component; import tech.powerjob.worker.core.processor.ProcessResult; import tech.powerjob.worker.core.processor.TaskContext; import tech.powerjob.worker.core.processor.sdk.BasicProcessor; import java.util.Date; @Component public class NoticeProcessors implements BasicProcessor { @Autowired private JavaMailSender javaMailSender; @Override public ProcessResult process(TaskContext taskContext) throws Exception { //创建简单的邮件发送对象 SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(taskContext.getJobParams()+"<[email protected]>"); // 设置发件人邮箱(若配置默认邮箱则不用再设置) message.setTo("[email protected]"); // 设置收件人邮箱 message.setCc("[email protected]"); // 设置抄报人邮箱(可以不填写) message.setBcc("[email protected]"); // 设置密送人邮箱(可以不填写) message.setSubject("打卡提醒"); // 设置邮件主题 message.setText("新的一天开始了,别忘记打卡哟!!!"); // 设置邮件文本内容 message.setSentDate(new Date()); // 设置邮件发送时间 //发送 javaMailSender.send(message); boolean success = true; return new ProcessResult(success, taskContext + ": " + success); } }
当然也可以自己单独建一个模块
五、PowerJob配置
六、测试
标签:接入,worker,Ruoyi,powerjob,tech,PowerJob,import,message From: https://www.cnblogs.com/mangoubiubiu/p/17280540.html