package cn.newfeifan.mall.module.sale.login;

import cn.newfeifan.mall.module.sale.service.merchant.MerchantService;
import cn.newfeifan.mall.module.system.mq.message.login.LoginSendMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class LoginConsumer {
    @Resource
    private MerchantService mailSendService;

    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(LoginSendMessage message) {
        log.info("[onMessage][消息内容({})]", message);
        mailSendService.doSendMail(message);
    }

}
