package cn.estsh.i3plus.core.apiservice.mq;

import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.TestBase;
import cn.estsh.i3plus.core.apiservice.util.MailUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import org.junit.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description :
 * @Reference :
 * @Author : yunhao
 * @CreateDate : 2018-11-15 13:22
 * @Modify:
 **/
public class TestMQ extends TestBase {

    /**
     * rabbitMQ队列
     */
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private MailUtil mailUtil;

    @Test
    public void sendMail() throws InterruptedException {

        SysMessage sysMessage = new SysMessage();
        sysMessage.setMessageTitle("test-系统通知");
        sysMessage.setMessageSenderNameRdd("system");
        sysMessage.setMessageSenderId(-1L);
        sysMessage.setMessageType(ImppEnumUtil.MESSAGE_TYPE.MAIL.getValue());
        sysMessage.setMessageSendTime("2018-11-01 16:58:00");

        for (int i = 0; i < 50; i++) {
            sysMessage = new SysMessage();
            sysMessage.setId(null);
            sysMessage.setMessageTitle( i + "mail测试");
            sysMessage.setMessageSenderNameRdd(i+"");
            rabbitTemplate.convertAndSend("WYH_MESSAGE_QUEUE", new SysMessage());
            System.out.println("第" + i + "次");
        }

    }

}
