package com.hotent.portal.jms.impl;


import com.hotent.base.jms.JmsHandler;
import com.hotent.base.jms.JmsMessage;
import com.hotent.base.jms.JmsProducer;
import com.hotent.base.jms.Notice;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: Cola
 * @Date: 2021/09/02/17:16
 * @Description: 外部系统(针对外部表单业务)消息处理器
 **/
@Service
public class ExternalHandler implements JmsHandler {
    private final Logger logger= LoggerFactory.getLogger(ExternalHandler.class);

    @Autowired
    private JmsProducer jmsProducer;

    public boolean send(Notice notice, String queueName) {
        try {
            jmsProducer.sendToQueue(notice,queueName);
            logger.debug("[JMS]:发送成功，队列名：{}，发送者ID：{}",queueName,notice.getSenderId());
        }catch (Exception e){
            e.printStackTrace();
            logger.error("[JMS]：发送消息失败，队列名：{}，发送者ID：{}，失败原因：{}",queueName,notice.getSenderId(),e.getMessage());
            return false;
        }
        return true;
    }
    @Override
    public boolean send(JmsMessage jmsMessage) {
        return false;
    }

    @Override
    public String getType() {
        return null;
    }

    @Override
    public String getTitle() {
        return null;
    }

    @Override
    public boolean getIsDefault() {
        return false;
    }

    @Override
    public boolean getSupportHtml() {
        return false;
    }

}
