package com.bohuikeji.frame.module.admin.thread;

import com.bohuikeji.frame.module.admin.base.MqListener;
import lombok.extern.slf4j.Slf4j;

/**
 * 消息队列消费者业务处理线程
 * @author 孙劲辉
 */
@Slf4j
public class MqListenerThread implements Runnable{

    private MqListener listener;
    private Object msg;

    public MqListenerThread(MqListener listener, Object msg){
        this.listener=listener;
        this.msg=msg;
    }

    @Override
    public void run() {
        try {
            listener.onReceive(msg);
        }catch (Exception e){
            StackTraceElement taskInfo=e.getStackTrace()[0];
            log.error("【消息队列监听者业务异常】位于：{}({})行",taskInfo.getClassName(),taskInfo.getLineNumber(),e);
            listener.onError(msg,e);
        }

    }

}
