Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
713bb988
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
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看板
提交
713bb988
编写于
7月 31, 2019
作者:
V
vongosling
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor the protection logic when pulling
上级
b39031a7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
18 deletion
+18
-18
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+18
-18
未找到文件。
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
浏览文件 @
713bb988
...
...
@@ -94,13 +94,13 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public
void
createTopic
(
String
key
,
String
newTopic
,
int
queueNum
,
int
topicSysFlag
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
this
.
mQClientFactory
.
getMQAdminImpl
().
createTopic
(
key
,
newTopic
,
queueNum
,
topicSysFlag
);
}
private
void
makeSureStateOK
()
throws
MQClientException
{
private
void
isRunning
()
throws
MQClientException
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
throw
new
MQClientException
(
"The consumer
service state not OK
, "
throw
new
MQClientException
(
"The consumer
is not in running status
, "
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
...
...
@@ -108,12 +108,12 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public
long
fetchConsumeOffset
(
MessageQueue
mq
,
boolean
fromStore
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
offsetStore
.
readOffset
(
mq
,
fromStore
?
ReadOffsetType
.
READ_FROM_STORE
:
ReadOffsetType
.
MEMORY_FIRST_THEN_STORE
);
}
public
Set
<
MessageQueue
>
fetchMessageQueuesInBalance
(
String
topic
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
if
(
null
==
topic
)
{
throw
new
IllegalArgumentException
(
"topic is null"
);
}
...
...
@@ -130,12 +130,12 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public
List
<
MessageQueue
>
fetchPublishMessageQueues
(
String
topic
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
fetchPublishMessageQueues
(
topic
);
}
public
Set
<
MessageQueue
>
fetchSubscribeMessageQueues
(
String
topic
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
// check if has info in memory, otherwise invoke api.
Set
<
MessageQueue
>
result
=
this
.
rebalanceImpl
.
getTopicSubscribeInfoTable
().
get
(
topic
);
if
(
null
==
result
)
{
...
...
@@ -156,17 +156,17 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public
long
earliestMsgStoreTime
(
MessageQueue
mq
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
earliestMsgStoreTime
(
mq
);
}
public
long
maxOffset
(
MessageQueue
mq
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
maxOffset
(
mq
);
}
public
long
minOffset
(
MessageQueue
mq
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
minOffset
(
mq
);
}
...
...
@@ -225,7 +225,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private
PullResult
pullSyncImpl
(
MessageQueue
mq
,
SubscriptionData
subscriptionData
,
long
offset
,
int
maxNums
,
boolean
block
,
long
timeout
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
if
(
null
==
mq
)
{
throw
new
MQClientException
(
"mq is null"
,
null
);
...
...
@@ -383,7 +383,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
@Override
public
void
persistConsumerOffset
()
{
try
{
this
.
makeSureStateOK
();
this
.
isRunning
();
Set
<
MessageQueue
>
mqs
=
new
HashSet
<
MessageQueue
>();
Set
<
MessageQueue
>
allocateMq
=
this
.
rebalanceImpl
.
getProcessQueueTable
().
keySet
();
mqs
.
addAll
(
allocateMq
);
...
...
@@ -466,7 +466,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
final
PullCallback
pullCallback
,
final
boolean
block
,
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
if
(
null
==
mq
)
{
throw
new
MQClientException
(
"mq is null"
,
null
);
...
...
@@ -543,18 +543,18 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
public
QueryResult
queryMessage
(
String
topic
,
String
key
,
int
maxNum
,
long
begin
,
long
end
)
throws
MQClientException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
queryMessage
(
topic
,
key
,
maxNum
,
begin
,
end
);
}
public
MessageExt
queryMessageByUniqKey
(
String
topic
,
String
uniqKey
)
throws
MQClientException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
queryMessageByUniqKey
(
topic
,
uniqKey
);
}
public
long
searchOffset
(
MessageQueue
mq
,
long
timestamp
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
searchOffset
(
mq
,
timestamp
);
}
...
...
@@ -748,13 +748,13 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
}
public
void
updateConsumeOffset
(
MessageQueue
mq
,
long
offset
)
throws
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
this
.
offsetStore
.
updateOffset
(
mq
,
offset
,
false
);
}
public
MessageExt
viewMessage
(
String
msgId
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
this
.
makeSureStateOK
();
this
.
isRunning
();
return
this
.
mQClientFactory
.
getMQAdminImpl
().
viewMessage
(
msgId
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录