package com.jianshui.queue.dto;

import com.alibaba.fastjson.JSONObject;

/**
 * @Description
 * @Author 巩权林
 * @Date 2021-11-25 10:03
 **/
public class RedisQueueMessage {

    // 消息内容
    private Object data;

    // 消息失败时重试次数
    private Integer retry = 0;

    // 消息class类型
    private String dataClassName;

    // 队列名称
    private String queueName;


    // 定义一个带参数的构造方法方便初始化
    public RedisQueueMessage(Object data) {
        this.data = JSONObject.toJSONString(data);
        if (data == null) {
            this.dataClassName = "";
        } else {
            this.dataClassName = data.getClass().getName();
        }
    }

    public RedisQueueMessage(Object data, Integer retry) {
        if (data != null) {
            this.data = data;
            this.dataClassName = data.getClass().getName();
            this.retry = retry;
        }
    }

    public Object getData() {
        return this.data;
    }

    public String getDataClassName() {
        return this.dataClassName;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getRetry() {
        return retry;
    }

    public void setRetry(Integer retry) {
        this.retry = retry;
    }

    public String getQueueName() {
        return queueName;
    }

    public void setQueueName(String queueName) {
        this.queueName = queueName;
    }
}
