潘志宝
2024-08-21 c39abccd937de093fc067abffac5f66b758bc97b
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.mq.consumer.sms;
H 2
3 import com.iailab.module.system.mq.message.sms.SmsSendMessage;
4 import com.iailab.module.system.service.sms.SmsSendService;
5 import lombok.extern.slf4j.Slf4j;
6 import org.springframework.context.event.EventListener;
7 import org.springframework.scheduling.annotation.Async;
8 import org.springframework.stereotype.Component;
9
10 import javax.annotation.Resource;
11
12 /**
13  * 针对 {@link SmsSendMessage} 的消费者
14  *
15  * @author zzf
16  */
17 @Component
18 @Slf4j
19 public class SmsSendConsumer {
20
21     @Resource
22     private SmsSendService smsSendService;
23
24     @EventListener
25     @Async // Spring Event 默认在 Producer 发送的线程,通过 @Async 实现异步
26     public void onMessage(SmsSendMessage message) {
27         log.info("[onMessage][消息内容({})]", message);
28         smsSendService.doSendSms(message);
29     }
30
31 }