Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
3c264c8f
R
Rocketmq
项目概览
小五666\n哈哈
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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看板
提交
3c264c8f
编写于
2月 19, 2019
作者:
S
ShannonDing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish push message process in client(add broker name)
上级
8e124956
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
16 deletion
+28
-16
client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
.../apache/rocketmq/client/impl/ClientRemotingProcessor.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+22
-14
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
...apache/rocketmq/client/impl/factory/MQClientInstance.java
+5
-1
未找到文件。
client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
浏览文件 @
3c264c8f
...
...
@@ -218,12 +218,12 @@ public class ClientRemotingProcessor implements RequestProcessor {
final
PushMessageHeader
requestHeader
=
(
PushMessageHeader
)
request
.
decodeCommandCustomHeader
(
PushMessageHeader
.
class
);
final
MessageExt
msg
=
MessageDecoder
.
decode
(
ByteBuffer
.
wrap
(
request
.
getBody
()));
boolean
result
=
this
.
mqClientFactory
.
processSnodePushMessage
(
msg
,
requestHeader
.
getConsumerGroup
(),
requestHeader
.
getTopic
(),
requestHeader
.
getEnodeName
(),
requestHeader
.
getQueueId
(),
requestHeader
.
getQueueOffset
());
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
浏览文件 @
3c264c8f
...
...
@@ -308,12 +308,13 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public
void
onSuccess
(
PullResult
pullResult
)
{
if
(
pullResult
!=
null
)
{
//Update local offset according remote offset
String
localOffsetKey
=
pullRequest
.
getConsumerGroup
()
+
"@"
+
pullRequest
.
getMessageQueue
().
getTopic
()
+
"@"
+
pullRequest
.
getMessageQueue
().
getQueueId
();
String
localOffsetKey
=
genLocalOffsetKey
(
pullRequest
.
getConsumerGroup
(),
pullRequest
.
getMessageQueue
().
getTopic
(),
pullRequest
.
getMessageQueue
().
getBrokerName
(),
pullRequest
.
getMessageQueue
().
getQueueId
());
AtomicLong
localOffset
=
localConsumerOffset
.
get
(
localOffsetKey
);
if
(
localOffset
==
null
)
{
localConsumerOffset
.
put
(
localOffsetKey
,
new
AtomicLong
(-
1
));
localConsumerOffset
.
put
IfAbsent
(
localOffsetKey
,
new
AtomicLong
(-
1
));
}
localConsumerOffset
.
get
(
localOffsetKey
).
set
(
pullResult
.
getNextBeginOffset
());
...
...
@@ -474,9 +475,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
private
void
executePullRequestLater
(
final
PullRequest
pullRequest
,
final
long
timeDelay
)
{
String
localOffsetKey
=
pullRequest
.
getConsumerGroup
()
+
"@"
+
pullRequest
.
getMessageQueue
().
getTopic
()
+
"@"
+
pullRequest
.
getMessageQueue
().
getQueueId
();
String
localOffsetKey
=
genLocalOffsetKey
(
pullRequest
.
getConsumerGroup
(),
pullRequest
.
getMessageQueue
().
getTopic
(),
pullRequest
.
getMessageQueue
().
getBrokerName
(),
pullRequest
.
getMessageQueue
().
getQueueId
());
if
(
pullStopped
.
get
(
localOffsetKey
)
!=
null
&&
pullStopped
.
get
(
localOffsetKey
).
get
())
{
//Stop pull request
log
.
info
(
"Stop pull request, {}"
,
localOffsetKey
);
...
...
@@ -498,9 +500,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
public
void
executePullRequestImmediately
(
final
PullRequest
pullRequest
)
{
String
localOffsetKey
=
pullRequest
.
getConsumerGroup
()
+
"@"
+
pullRequest
.
getMessageQueue
().
getTopic
()
+
"@"
+
pullRequest
.
getMessageQueue
().
getQueueId
();
String
localOffsetKey
=
genLocalOffsetKey
(
pullRequest
.
getConsumerGroup
(),
pullRequest
.
getMessageQueue
().
getTopic
(),
pullRequest
.
getMessageQueue
().
getBrokerName
(),
pullRequest
.
getMessageQueue
().
getQueueId
());
if
(
pullStopped
.
get
(
localOffsetKey
)
!=
null
&&
pullStopped
.
get
(
localOffsetKey
).
get
())
{
//Stop pull request
log
.
info
(
"Stop pull request, {}"
,
localOffsetKey
);
...
...
@@ -1197,21 +1200,23 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public
boolean
processPushMessage
(
final
MessageExt
msg
,
final
String
consumerGroup
,
final
String
topic
,
final
String
brokerName
,
final
int
queueID
,
final
long
offset
)
{
String
localOffsetKey
=
consumerGroup
+
"@"
+
topic
+
"@"
+
queueID
;
String
localOffsetKey
=
genLocalOffsetKey
(
consumerGroup
,
topic
,
brokerName
,
queueID
)
;
AtomicLong
localOffset
=
this
.
localConsumerOffset
.
get
(
localOffsetKey
);
if
(
localOffset
==
null
)
{
log
.
info
(
"Current Local offset have not set, initiallized to -1."
);
this
.
localConsumerOffset
.
put
(
localOffsetKey
,
new
AtomicLong
(-
1
));
return
false
;
}
if
(
localOffset
.
get
()
<
offset
)
{
if
(
localOffset
.
get
()
+
1
<
offset
)
{
//should start pull message process
log
.
debug
(
"Current Local key:{} and offset:{} and push offset:{}"
,
localOffsetKey
,
localOffset
.
get
(),
offset
);
return
false
;
}
else
{
//Stop pull request
log
.
debug
(
"Process Push : Current Local key:{} and offset:{} and push offset:{}"
,
localOffsetKey
,
localOffset
.
get
(),
offset
);
AtomicBoolean
pullStop
=
this
.
pullStopped
.
get
(
localOffsetKey
);
if
(
pullStop
==
null
)
{
this
.
pullStopped
.
put
(
localOffsetKey
,
new
AtomicBoolean
(
true
));
...
...
@@ -1233,10 +1238,13 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
processQueue
=
processQueues
.
get
(
localOffsetKey
);
}
processQueue
.
putMessage
(
messageExtList
);
MessageQueue
messageQueue
=
new
MessageQueue
(
topic
,
""
,
queueID
);
MessageQueue
messageQueue
=
new
MessageQueue
(
topic
,
brokerName
,
queueID
);
this
.
consumeMessageService
.
submitConsumeRequest
(
messageExtList
,
processQueue
,
messageQueue
,
true
);
log
.
info
(
".......submitConsumeRequest:{},Offset:{}..."
,
localOffsetKey
,
offset
);
}
return
true
;
}
private
String
genLocalOffsetKey
(
String
consumerGroup
,
String
topic
,
String
brokerName
,
int
queueID
)
{
return
consumerGroup
+
"@"
+
topic
+
"@"
+
brokerName
+
"@"
+
queueID
;
}
}
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
浏览文件 @
3c264c8f
...
...
@@ -1376,15 +1376,19 @@ public class MQClientInstance {
public
ClientConfig
getNettyClientConfig
()
{
return
nettyClientConfig
;
}
public
boolean
processSnodePushMessage
(
final
MessageExt
msg
,
final
String
consumerGroup
,
final
String
topic
,
final
String
brokerName
,
final
int
queueID
,
final
long
offset
)
{
log
.
debug
(
"Recieve:processSnodePushMessage :{}-{}-{}-{}-{}"
,
consumerGroup
,
topic
,
brokerName
,
queueID
,
offset
);
MQConsumerInner
mqConsumerInner
=
this
.
consumerTable
.
get
(
consumerGroup
);
if
(
null
!=
mqConsumerInner
)
{
DefaultMQPushConsumerImpl
consumer
=
(
DefaultMQPushConsumerImpl
)
mqConsumerInner
;
consumer
.
processPushMessage
(
msg
,
consumerGroup
,
topic
,
queueID
,
offset
);
consumer
.
processPushMessage
(
msg
,
consumerGroup
,
topic
,
brokerName
,
queueID
,
offset
);
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录