全站最硬核 百万字强肝RocketMq源码 火热更新中~(四十三)

接下来的几个方法都是如出一辙了

对resource集合内的所有资源路径

都做 包namespace 去namespace 等操作

继续往下:

public MessageQueue queueWithNamespace(MessageQueue queue) {
    if (StringUtils.isEmpty(this.getNamespace())) {
        return queue;
    }
    return new MessageQueue(withNamespace(queue.getTopic()), queue.getBrokerName(), queue.getQueueId());
}

public Collection<MessageQueue> queuesWithNamespace(Collection<MessageQueue> queues) {
    if (StringUtils.isEmpty(this.getNamespace())) {
        return queues;
    }
    Iterator<MessageQueue> iter = queues.iterator();
    while (iter.hasNext()) {
        MessageQueue queue = iter.next();
        queue.setTopic(withNamespace(queue.getTopic()));
    }
    return queues;
}

在这儿我们第一次接触到“消息队列”

消息队列的三要素:Topic,BrokerName,QueueId

然后这里的两个方法,给Topic包上了NameSpace

刚好ClientConfig这个类我们也读完了,正好把MessageQueue过一遍

org.apache.rocketmq.common.message.MessageQueue

private static final long serialVersionUID = 6191200464116433425L;
private String topic;
private String brokerName;
private int queueId;

public MessageQueue() {

}

public MessageQueue(String topic, String brokerName, int queueId) {
    this.topic = topic;
    this.brokerName = brokerName;
    this.queueId = queueId;
}

首先是消息队列的三要素

然后是空参构造和全参构造

public String getTopic() {
    return topic;
}

public void setTopic(String topic) {
    this.topic = topic;
}

public String getBrokerName() {
    return brokerName;
}

public void setBrokerName(String brokerName) {
    this.brokerName = brokerName;
}

public int getQueueId() {
    return queueId;
}

public void setQueueId(int queueId) {
    this.queueId = queueId;
}

@Override
public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((brokerName == null) ? 0 : brokerName.hashCode());
    result = prime * result + queueId;
    result = prime * result + ((topic == null) ? 0 : topic.hashCode());
    return result;
}

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    MessageQueue other = (MessageQueue) obj;
    if (brokerName == null) {
        if (other.brokerName != null)
            return false;
    } else if (!brokerName.equals(other.brokerName))
        return false;
    if (queueId != other.queueId)
        return false;
    if (topic == null) {
        if (other.topic != null)
            return false;
    } else if (!topic.equals(other.topic))
        return false;
    return true;
}

@Override
public String toString() {
    return "MessageQueue [topic=" + topic + ", brokerName=" + brokerName + ", queueId=" + queueId + "]";
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值