Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
f308cd30
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f308cd30
编写于
11月 09, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert mq to broker name
上级
c0ffc5bd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
50 deletion
+29
-50
client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
...ain/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+8
-9
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+9
-4
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
...apache/rocketmq/client/impl/factory/MQClientInstance.java
+7
-22
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
.../rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+5
-15
未找到文件。
client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
浏览文件 @
f308cd30
...
...
@@ -41,7 +41,6 @@ import org.apache.rocketmq.common.protocol.header.QueryMessageRequestHeader;
import
org.apache.rocketmq.common.protocol.header.QueryMessageResponseHeader
;
import
org.apache.rocketmq.common.protocol.route.BrokerData
;
import
org.apache.rocketmq.common.protocol.route.LogicalQueueRouteData
;
import
org.apache.rocketmq.common.protocol.route.LogicalQueuesInfo
;
import
org.apache.rocketmq.common.protocol.route.TopicRouteData
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.remoting.InvokeCallback
;
...
...
@@ -191,10 +190,10 @@ public class MQAdminImpl {
if
(
logicalQueueRouteData
!=
null
)
{
mq
=
logicalQueueRouteData
.
getMessageQueue
();
}
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
if
(
null
==
brokerAddr
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
}
if
(
brokerAddr
!=
null
)
{
...
...
@@ -227,10 +226,10 @@ public class MQAdminImpl {
previousQueueRouteData
=
maxQueueRouteData
;
mq
=
maxQueueRouteData
.
getMessageQueue
();
}
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
if
(
null
==
brokerAddr
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
topic
);
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
}
if
(
brokerAddr
!=
null
)
{
...
...
@@ -256,10 +255,10 @@ public class MQAdminImpl {
mq
=
minQueueRouteData
.
getMessageQueue
();
}
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
if
(
null
==
brokerAddr
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
}
if
(
brokerAddr
!=
null
)
{
...
...
@@ -298,10 +297,10 @@ public class MQAdminImpl {
mq
=
minQueueRouteData
.
getMessageQueue
();
}
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
if
(
null
==
brokerAddr
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
)
);
}
if
(
brokerAddr
!=
null
)
{
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
浏览文件 @
f308cd30
...
...
@@ -718,11 +718,16 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
private
void
sendMessageBack
(
MessageExt
msg
,
int
delayLevel
,
final
String
brokerName
,
final
MessageQueue
mq
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
try
{
String
desBrokerName
=
brokerName
;
if
(
mq
!=
null
)
{
String
tmpBrokerName
=
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
);
if
(
tmpBrokerName
!=
null
)
{
desBrokerName
=
tmpBrokerName
;
}
}
String
brokerAddr
=
null
;
if
(
null
!=
mq
)
{
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
}
else
if
(
null
!=
brokerName
)
{
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
brokerName
);
if
(
null
!=
desBrokerName
)
{
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
desBrokerName
);
}
else
{
RemotingHelper
.
parseSocketAddressAddr
(
msg
.
getStoreHost
());
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
浏览文件 @
f308cd30
...
...
@@ -1055,16 +1055,11 @@ public class MQClientInstance {
return
mq
.
getBrokerName
();
}
public
FindBrokerResult
findBrokerAddressInAdmin
(
final
MessageQueue
mq
)
{
String
brokerName
=
getBrokerNameFromMessageQueue
(
mq
);
public
FindBrokerResult
findBrokerAddressInAdmin
(
final
String
brokerName
)
{
if
(
brokerName
==
null
)
{
return
null
;
}
else
{
return
findBrokerAddressInAdmin
(
brokerName
);
}
}
public
FindBrokerResult
findBrokerAddressInAdmin
(
final
String
brokerName
)
{
String
brokerAddr
=
null
;
boolean
slave
=
false
;
boolean
found
=
false
;
...
...
@@ -1094,16 +1089,11 @@ public class MQClientInstance {
return
null
;
}
public
String
findBrokerAddressInPublish
(
final
MessageQueue
mq
)
{
String
brokerName
=
getBrokerNameFromMessageQueue
(
mq
);
public
String
findBrokerAddressInPublish
(
final
String
brokerName
)
{
if
(
brokerName
==
null
)
{
return
null
;
}
else
{
return
findBrokerAddressInPublish
(
brokerName
);
}
}
//This is used for retry only
public
String
findBrokerAddressInPublish
(
final
String
brokerName
)
{
HashMap
<
Long
/* brokerId */
,
String
/* address */
>
map
=
this
.
brokerAddrTable
.
get
(
brokerName
);
if
(
map
!=
null
&&
!
map
.
isEmpty
())
{
return
map
.
get
(
MixAll
.
MASTER_ID
);
...
...
@@ -1112,20 +1102,15 @@ public class MQClientInstance {
return
null
;
}
public
FindBrokerResult
findBrokerAddressInSubscribe
(
final
MessageQueue
mq
,
final
long
brokerId
,
final
boolean
onlyThisBroker
)
{
String
brokerName
=
getBrokerNameFromMessageQueue
(
mq
);
if
(
brokerName
==
null
)
{
return
null
;
}
else
{
return
findBrokerAddressInSubscribe
(
brokerName
,
brokerId
,
onlyThisBroker
);
}
}
public
FindBrokerResult
findBrokerAddressInSubscribe
(
final
String
brokerName
,
final
long
brokerId
,
final
boolean
onlyThisBroker
)
{
if
(
brokerName
==
null
)
{
return
null
;
}
String
brokerAddr
=
null
;
boolean
slave
=
false
;
boolean
found
=
false
;
...
...
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
浏览文件 @
f308cd30
...
...
@@ -16,16 +16,12 @@
*/
package
org.apache.rocketmq.client.impl.producer
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.base.Objects
;
import
java.io.IOException
;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Random
;
import
java.util.Set
;
import
java.util.concurrent.BlockingQueue
;
...
...
@@ -45,7 +41,6 @@ import org.apache.rocketmq.client.Validators;
import
org.apache.rocketmq.client.common.ClientErrorCode
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.exception.MQRedirectException
;
import
org.apache.rocketmq.client.exception.RequestTimeoutException
;
import
org.apache.rocketmq.client.hook.CheckForbiddenContext
;
import
org.apache.rocketmq.client.hook.CheckForbiddenHook
;
...
...
@@ -67,7 +62,6 @@ import org.apache.rocketmq.client.producer.RequestFutureTable;
import
org.apache.rocketmq.client.producer.RequestResponseFuture
;
import
org.apache.rocketmq.client.producer.SendCallback
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.apache.rocketmq.client.producer.SendResultForLogicalQueue
;
import
org.apache.rocketmq.client.producer.SendStatus
;
import
org.apache.rocketmq.client.producer.TransactionCheckListener
;
import
org.apache.rocketmq.client.producer.TransactionListener
;
...
...
@@ -88,13 +82,9 @@ import org.apache.rocketmq.common.message.MessageId;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.message.MessageType
;
import
org.apache.rocketmq.common.protocol.NamespaceUtil
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader
;
import
org.apache.rocketmq.common.protocol.route.LogicalQueueRouteData
;
import
org.apache.rocketmq.common.protocol.route.LogicalQueuesInfo
;
import
org.apache.rocketmq.common.protocol.route.TopicRouteData
;
import
org.apache.rocketmq.common.sysflag.MessageSysFlag
;
import
org.apache.rocketmq.common.utils.CorrelationIdUtil
;
import
org.apache.rocketmq.logging.InternalLogger
;
...
...
@@ -731,14 +721,13 @@ public class DefaultMQProducerImpl implements MQProducerInner {
final
TopicPublishInfo
topicPublishInfo
,
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
long
beginStartTime
=
System
.
currentTimeMillis
();
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
String
brokerName
=
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
);
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
brokerName
);
if
(
null
==
brokerAddr
)
{
tryToFindTopicPublishInfo
(
mq
.
getTopic
());
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
);
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
brokerName
);
}
String
brokerName
=
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
mq
);
SendMessageContext
context
=
null
;
if
(
brokerAddr
!=
null
)
{
brokerAddr
=
MixAll
.
brokerVIPChannel
(
this
.
defaultMQProducer
.
isSendMessageWithVIPChannel
(),
brokerAddr
);
...
...
@@ -1342,7 +1331,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
id
=
MessageDecoder
.
decodeMessageId
(
sendResult
.
getMsgId
());
}
String
transactionId
=
sendResult
.
getTransactionId
();
final
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
sendResult
.
getMessageQueue
());
final
String
destBrokerName
=
this
.
mQClientFactory
.
getBrokerNameFromMessageQueue
(
defaultMQProducer
.
queueWithNamespace
(
sendResult
.
getMessageQueue
()));
final
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
destBrokerName
);
EndTransactionRequestHeader
requestHeader
=
new
EndTransactionRequestHeader
();
requestHeader
.
setTransactionId
(
transactionId
);
requestHeader
.
setCommitLogOffset
(
id
.
getOffset
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录