【新增】模块exam,judgement并修改pom文件,新增rabbitmq依赖
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package pc.exam.pp.module.system.mq.consumer.sms;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import pc.exam.pp.module.system.mq.message.sms.SmsSendMessage;
|
||||
import pc.exam.pp.module.system.service.sms.SmsSendService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -15,6 +16,7 @@ import jakarta.annotation.Resource;
|
||||
* @author zzf
|
||||
*/
|
||||
@Component
|
||||
@RabbitListener(queues = SmsSendMessage.QUEUE)
|
||||
@Slf4j
|
||||
public class SmsSendConsumer {
|
||||
|
||||
|
@@ -14,6 +14,8 @@ import java.util.List;
|
||||
@Data
|
||||
public class SmsSendMessage {
|
||||
|
||||
public static final String QUEUE = "SEND_MESSAGE_QUEUE"; // 重点:需要增加消息对应的 Queue
|
||||
|
||||
/**
|
||||
* 短信日志编号
|
||||
*/
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package pc.exam.pp.module.system.mq.producer.sms;
|
||||
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import pc.exam.pp.framework.common.core.KeyValue;
|
||||
import pc.exam.pp.module.system.mq.message.sms.SmsSendMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -21,7 +22,23 @@ public class SmsProducer {
|
||||
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Resource
|
||||
private RabbitTemplate rabbitTemplate; // 重点:注入 RabbitTemplate 对象
|
||||
/**
|
||||
* 发送 {@link SmsSendMessage} 消息
|
||||
*
|
||||
* @param logId 短信日志编号
|
||||
* @param mobile 手机号
|
||||
* @param channelId 渠道编号
|
||||
* @param apiTemplateId 短信模板编号
|
||||
* @param templateParams 短信模板参数
|
||||
*/
|
||||
// public void sendSmsSendMessage(Long logId, String mobile,
|
||||
// Long channelId, String apiTemplateId, List<KeyValue<String, Object>> templateParams) {
|
||||
// SmsSendMessage message = new SmsSendMessage().setLogId(logId).setMobile(mobile);
|
||||
// message.setChannelId(channelId).setApiTemplateId(apiTemplateId).setTemplateParams(templateParams);
|
||||
// applicationContext.publishEvent(message);
|
||||
// }
|
||||
/**
|
||||
* 发送 {@link SmsSendMessage} 消息
|
||||
*
|
||||
@@ -35,7 +52,7 @@ public class SmsProducer {
|
||||
Long channelId, String apiTemplateId, List<KeyValue<String, Object>> templateParams) {
|
||||
SmsSendMessage message = new SmsSendMessage().setLogId(logId).setMobile(mobile);
|
||||
message.setChannelId(channelId).setApiTemplateId(apiTemplateId).setTemplateParams(templateParams);
|
||||
applicationContext.publishEvent(message);
|
||||
rabbitTemplate.convertAndSend(SmsSendMessage.QUEUE, message); // 重点:使用 RabbitTemplate 发送消息
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user