package com.foreverwin.mesnac.common.util;

import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

/**
 * @Description TODO
 * @Author zhaojiawei
 * @Since 2021-07-21
 */
@Component
public class ActiveMQUtil {


    @Autowired
    private JmsMessagingTemplate mesJmsTemplate;

    public void wechatSendMessage(String user, String text) {
            String queue = "send.weChat.notice";
            JSONObject jsonObject = new JSONObject();
            try{
                jsonObject.put("TO_USER", user);
                jsonObject.put("CONTENT",text);
               // defaultJmsTemplate.getJmsTemplate().setReceiveTimeout(TimeUnit.SECONDS.toMillis(3));
                mesJmsTemplate.convertAndSend(queue, jsonObject.toString());
//                if (StringUtil.isBlank(message)) {
//                    //记日志
//                }
            }catch (Exception ignored){
//                throw new BaseException("消息发送失败");
            }
    }
}
