From d03e46a4cb0be50401a4fcd9132392a6dde43861 Mon Sep 17 00:00:00 2001 From: uglycow Date: Fri, 14 Feb 2020 15:45:59 +0800 Subject: [PATCH] [ISSUE #1771]add MessageExt.getBrokerName for issue (#1772) * typo fix * add MessageExt.getBrokerName() * add brokerName for toString * get brokerName from mq --- .../client/impl/consumer/PullAPIWrapper.java | 1 + .../apache/rocketmq/common/message/MessageExt.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java index 1917d27c..231ac0c6 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/PullAPIWrapper.java @@ -104,6 +104,7 @@ public class PullAPIWrapper { Long.toString(pullResult.getMinOffset())); MessageAccessor.putProperty(msg, MessageConst.PROPERTY_MAX_OFFSET, Long.toString(pullResult.getMaxOffset())); + msg.setBrokerName(mq.getBrokerName()); } pullResultExt.setMsgFoundList(msgListFilterAgain); diff --git a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java index 20cb0572..7f351725 100644 --- a/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java +++ b/common/src/main/java/org/apache/rocketmq/common/message/MessageExt.java @@ -27,6 +27,8 @@ import org.apache.rocketmq.common.sysflag.MessageSysFlag; public class MessageExt extends Message { private static final long serialVersionUID = 5720810158625748049L; + private String brokerName; + private int queueId; private int storeSize; @@ -107,6 +109,14 @@ public class MessageExt extends Message { return socketAddress2ByteBuffer(this.storeHost, byteBuffer); } + public String getBrokerName() { + return brokerName; + } + + public void setBrokerName(String brokerName) { + this.brokerName = brokerName; + } + public int getQueueId() { return queueId; } @@ -235,7 +245,7 @@ public class MessageExt extends Message { @Override public String toString() { - return "MessageExt [queueId=" + queueId + ", storeSize=" + storeSize + ", queueOffset=" + queueOffset + return "MessageExt [brokerName=" + brokerName + ", queueId=" + queueId + ", storeSize=" + storeSize + ", queueOffset=" + queueOffset + ", sysFlag=" + sysFlag + ", bornTimestamp=" + bornTimestamp + ", bornHost=" + bornHost + ", storeTimestamp=" + storeTimestamp + ", storeHost=" + storeHost + ", msgId=" + msgId + ", commitLogOffset=" + commitLogOffset + ", bodyCRC=" + bodyCRC + ", reconsumeTimes=" -- GitLab