Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
7f96008c
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 3 年多
通知
295
Star
16140
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看板
提交
7f96008c
编写于
8月 11, 2017
作者:
Y
yukon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unused class GetRouteInfoResponseHeader and meaningless comments
上级
ffad6566
变更
62
隐藏空白更改
内联
并排
Showing
62 changed file
with
617 addition
and
781 deletion
+617
-781
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
...ain/java/org/apache/rocketmq/broker/BrokerController.java
+5
-6
broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
...c/main/java/org/apache/rocketmq/broker/BrokerStartup.java
+4
-4
broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
...ocketmq/broker/client/rebalance/RebalanceLockManager.java
+22
-22
broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
...apache/rocketmq/broker/filtersrv/FilterServerManager.java
+0
-2
broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
...cketmq/broker/processor/AbstractSendMessageProcessor.java
+4
-4
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+21
-28
broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
...pache/rocketmq/broker/processor/PullMessageProcessor.java
+8
-8
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
...pache/rocketmq/broker/processor/SendMessageProcessor.java
+14
-14
broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
...java/org/apache/rocketmq/broker/BrokerControllerTest.java
+4
-4
client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
.../rocketmq/client/consumer/store/LocalFileOffsetStore.java
+5
-5
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
...cketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+2
-2
client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
...ain/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
...java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+122
-125
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
...ient/impl/consumer/ConsumeMessageConcurrentlyService.java
+32
-34
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
...mq/client/impl/consumer/ConsumeMessageOrderlyService.java
+43
-43
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
.../rocketmq/client/impl/consumer/ConsumeMessageService.java
+4
-4
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+52
-52
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+31
-31
client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
...g/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
+11
-11
client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
...ache/rocketmq/client/impl/consumer/RebalancePushImpl.java
+2
-2
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
...apache/rocketmq/client/impl/factory/MQClientInstance.java
+13
-14
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
.../rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+46
-46
client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
...apache/rocketmq/client/impl/producer/MQProducerInner.java
+3
-3
common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
...src/main/java/org/apache/rocketmq/common/TopicConfig.java
+0
-10
common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
...src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
+13
-13
common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
...apache/rocketmq/common/message/MessageClientIDSetter.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
...he/rocketmq/common/protocol/body/ConsumerRunningInfo.java
+47
-47
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
.../common/protocol/header/GetConsumeStatsRequestHeader.java
+0
-2
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
...ommon/protocol/header/GetConsumerStatusRequestHeader.java
+0
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
...protocol/header/GetEarliestMsgStoretimeRequestHeader.java
+0
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
...q/common/protocol/header/QueryCorrectionOffsetHeader.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
...tmq/common/protocol/header/SearchOffsetRequestHeader.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
...common/protocol/header/UnregisterClientRequestHeader.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
...ommon/protocol/header/UnregisterClientResponseHeader.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
...n/protocol/header/namesrv/GetRouteInfoResponseHeader.java
+0
-33
common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
...tocol/header/namesrv/RegisterOrderTopicRequestHeader.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
...java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
+0
-4
common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
...in/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
+0
-2
example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
...java/org/apache/rocketmq/example/simple/PushConsumer.java
+0
-2
example/src/main/resources/MessageFilterImpl.java
example/src/main/resources/MessageFilterImpl.java
+1
-1
filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.java
...ava/org/apache/rocketmq/filter/parser/SelectorParser.java
+0
-1
filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.jj
.../java/org/apache/rocketmq/filter/parser/SelectorParser.jj
+0
-1
namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
...org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
+3
-3
namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
...g/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
+2
-2
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
...java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
+1
-1
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
...apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
+12
-12
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
...g/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+4
-4
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
...org/apache/rocketmq/remoting/netty/NettyServerConfig.java
+0
-4
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java
...org/apache/rocketmq/remoting/netty/NettySystemConfig.java
+9
-9
store/src/main/java/org/apache/rocketmq/store/CommitLog.java
store/src/main/java/org/apache/rocketmq/store/CommitLog.java
+41
-60
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
...n/java/org/apache/rocketmq/store/DefaultMessageStore.java
+24
-30
store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
.../main/java/org/apache/rocketmq/store/DispatchRequest.java
+0
-18
store/src/main/java/org/apache/rocketmq/store/MappedFile.java
...e/src/main/java/org/apache/rocketmq/store/MappedFile.java
+0
-2
store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
.../main/java/org/apache/rocketmq/store/MappedFileQueue.java
+0
-1
store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
.../main/java/org/apache/rocketmq/store/ha/HAConnection.java
+0
-8
store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
...src/main/java/org/apache/rocketmq/store/ha/HAService.java
+0
-18
store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
.../main/java/org/apache/rocketmq/store/index/IndexFile.java
+0
-1
store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
...ain/java/org/apache/rocketmq/store/index/IndexHeader.java
+0
-4
store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
...pache/rocketmq/store/schedule/ScheduleMessageService.java
+0
-3
store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
...ain/java/org/apache/rocketmq/store/stats/BrokerStats.java
+0
-2
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
...rg/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+3
-7
tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
...ocketmq/tools/command/message/PrintMessageSubCommand.java
+2
-3
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
浏览文件 @
7f96008c
...
@@ -135,11 +135,11 @@ public class BrokerController {
...
@@ -135,11 +135,11 @@ public class BrokerController {
private
BrokerFastFailure
brokerFastFailure
;
private
BrokerFastFailure
brokerFastFailure
;
private
Configuration
configuration
;
private
Configuration
configuration
;
public
BrokerController
(
//
public
BrokerController
(
final
BrokerConfig
brokerConfig
,
//
final
BrokerConfig
brokerConfig
,
final
NettyServerConfig
nettyServerConfig
,
//
final
NettyServerConfig
nettyServerConfig
,
final
NettyClientConfig
nettyClientConfig
,
//
final
NettyClientConfig
nettyClientConfig
,
final
MessageStoreConfig
messageStoreConfig
//
final
MessageStoreConfig
messageStoreConfig
)
{
)
{
this
.
brokerConfig
=
brokerConfig
;
this
.
brokerConfig
=
brokerConfig
;
this
.
nettyServerConfig
=
nettyServerConfig
;
this
.
nettyServerConfig
=
nettyServerConfig
;
...
@@ -255,7 +255,6 @@ public class BrokerController {
...
@@ -255,7 +255,6 @@ public class BrokerController {
this
.
registerProcessor
();
this
.
registerProcessor
();
// TODO remove in future
final
long
initialDelay
=
UtilAll
.
computNextMorningTimeMillis
()
-
System
.
currentTimeMillis
();
final
long
initialDelay
=
UtilAll
.
computNextMorningTimeMillis
()
-
System
.
currentTimeMillis
();
final
long
period
=
1000
*
60
*
60
*
24
;
final
long
period
=
1000
*
60
*
60
*
24
;
this
.
scheduledExecutorService
.
scheduleAtFixedRate
(
new
Runnable
()
{
this
.
scheduledExecutorService
.
scheduleAtFixedRate
(
new
Runnable
()
{
...
...
broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
浏览文件 @
7f96008c
...
@@ -190,10 +190,10 @@ public class BrokerStartup {
...
@@ -190,10 +190,10 @@ public class BrokerStartup {
MixAll
.
printObjectProperties
(
log
,
nettyClientConfig
);
MixAll
.
printObjectProperties
(
log
,
nettyClientConfig
);
MixAll
.
printObjectProperties
(
log
,
messageStoreConfig
);
MixAll
.
printObjectProperties
(
log
,
messageStoreConfig
);
final
BrokerController
controller
=
new
BrokerController
(
//
final
BrokerController
controller
=
new
BrokerController
(
brokerConfig
,
//
brokerConfig
,
nettyServerConfig
,
//
nettyServerConfig
,
nettyClientConfig
,
//
nettyClientConfig
,
messageStoreConfig
);
messageStoreConfig
);
// remember all configs to prevent discard
// remember all configs to prevent discard
controller
.
getConfiguration
().
registerConfig
(
properties
);
controller
.
getConfiguration
().
registerConfig
(
properties
);
...
...
broker/src/main/java/org/apache/rocketmq/broker/client/rebalance/RebalanceLockManager.java
浏览文件 @
7f96008c
...
@@ -52,9 +52,9 @@ public class RebalanceLockManager {
...
@@ -52,9 +52,9 @@ public class RebalanceLockManager {
lockEntry
=
new
LockEntry
();
lockEntry
=
new
LockEntry
();
lockEntry
.
setClientId
(
clientId
);
lockEntry
.
setClientId
(
clientId
);
groupValue
.
put
(
mq
,
lockEntry
);
groupValue
.
put
(
mq
,
lockEntry
);
log
.
info
(
"tryLock, message queue not locked, I got it. Group: {} NewClientId: {} {}"
,
//
log
.
info
(
"tryLock, message queue not locked, I got it. Group: {} NewClientId: {} {}"
,
group
,
//
group
,
clientId
,
//
clientId
,
mq
);
mq
);
}
}
...
@@ -69,19 +69,19 @@ public class RebalanceLockManager {
...
@@ -69,19 +69,19 @@ public class RebalanceLockManager {
lockEntry
.
setClientId
(
clientId
);
lockEntry
.
setClientId
(
clientId
);
lockEntry
.
setLastUpdateTimestamp
(
System
.
currentTimeMillis
());
lockEntry
.
setLastUpdateTimestamp
(
System
.
currentTimeMillis
());
log
.
warn
(
log
.
warn
(
"tryLock, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}"
,
//
"tryLock, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}"
,
group
,
//
group
,
oldClientId
,
//
oldClientId
,
clientId
,
//
clientId
,
mq
);
mq
);
return
true
;
return
true
;
}
}
log
.
warn
(
log
.
warn
(
"tryLock, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}"
,
//
"tryLock, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}"
,
group
,
//
group
,
oldClientId
,
//
oldClientId
,
clientId
,
//
clientId
,
mq
);
mq
);
return
false
;
return
false
;
}
finally
{
}
finally
{
...
@@ -144,9 +144,9 @@ public class RebalanceLockManager {
...
@@ -144,9 +144,9 @@ public class RebalanceLockManager {
lockEntry
.
setClientId
(
clientId
);
lockEntry
.
setClientId
(
clientId
);
groupValue
.
put
(
mq
,
lockEntry
);
groupValue
.
put
(
mq
,
lockEntry
);
log
.
info
(
log
.
info
(
"tryLockBatch, message queue not locked, I got it. Group: {} NewClientId: {} {}"
,
//
"tryLockBatch, message queue not locked, I got it. Group: {} NewClientId: {} {}"
,
group
,
//
group
,
clientId
,
//
clientId
,
mq
);
mq
);
}
}
...
@@ -162,20 +162,20 @@ public class RebalanceLockManager {
...
@@ -162,20 +162,20 @@ public class RebalanceLockManager {
lockEntry
.
setClientId
(
clientId
);
lockEntry
.
setClientId
(
clientId
);
lockEntry
.
setLastUpdateTimestamp
(
System
.
currentTimeMillis
());
lockEntry
.
setLastUpdateTimestamp
(
System
.
currentTimeMillis
());
log
.
warn
(
log
.
warn
(
"tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}"
,
//
"tryLockBatch, message queue lock expired, I got it. Group: {} OldClientId: {} NewClientId: {} {}"
,
group
,
//
group
,
oldClientId
,
//
oldClientId
,
clientId
,
//
clientId
,
mq
);
mq
);
lockedMqs
.
add
(
mq
);
lockedMqs
.
add
(
mq
);
continue
;
continue
;
}
}
log
.
warn
(
log
.
warn
(
"tryLockBatch, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}"
,
//
"tryLockBatch, message queue locked by other client. Group: {} OtherClientId: {} NewClientId: {} {}"
,
group
,
//
group
,
oldClientId
,
//
oldClientId
,
clientId
,
//
clientId
,
mq
);
mq
);
}
}
}
finally
{
}
finally
{
...
...
broker/src/main/java/org/apache/rocketmq/broker/filtersrv/FilterServerManager.java
浏览文件 @
7f96008c
...
@@ -111,9 +111,7 @@ public class FilterServerManager {
...
@@ -111,9 +111,7 @@ public class FilterServerManager {
}
}
}
}
/**
*/
public
void
scanNotActiveChannel
()
{
public
void
scanNotActiveChannel
()
{
Iterator
<
Entry
<
Channel
,
FilterServerInfo
>>
it
=
this
.
filterServerTable
.
entrySet
().
iterator
();
Iterator
<
Entry
<
Channel
,
FilterServerInfo
>>
it
=
this
.
filterServerTable
.
entrySet
().
iterator
();
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
浏览文件 @
7f96008c
...
@@ -189,10 +189,10 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
...
@@ -189,10 +189,10 @@ public abstract class AbstractSendMessageProcessor implements NettyRequestProces
}
}
log
.
warn
(
"the topic {} not exist, producer: {}"
,
requestHeader
.
getTopic
(),
ctx
.
channel
().
remoteAddress
());
log
.
warn
(
"the topic {} not exist, producer: {}"
,
requestHeader
.
getTopic
(),
ctx
.
channel
().
remoteAddress
());
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageMethod
(
//
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageMethod
(
requestHeader
.
getTopic
(),
//
requestHeader
.
getTopic
(),
requestHeader
.
getDefaultTopic
(),
//
requestHeader
.
getDefaultTopic
(),
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()),
//
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()),
requestHeader
.
getDefaultTopicQueueNums
(),
topicSysFlag
);
requestHeader
.
getDefaultTopicQueueNums
(),
topicSysFlag
);
if
(
null
==
topicConfig
)
{
if
(
null
==
topicConfig
)
{
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
7f96008c
...
@@ -116,6 +116,7 @@ import org.apache.rocketmq.store.SelectMappedBufferResult;
...
@@ -116,6 +116,7 @@ import org.apache.rocketmq.store.SelectMappedBufferResult;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
public
class
AdminBrokerProcessor
implements
NettyRequestProcessor
{
public
class
AdminBrokerProcessor
implements
NettyRequestProcessor
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
private
final
BrokerController
brokerController
;
private
final
BrokerController
brokerController
;
...
@@ -432,9 +433,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -432,9 +433,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
LockBatchRequestBody
requestBody
=
LockBatchRequestBody
.
decode
(
request
.
getBody
(),
LockBatchRequestBody
.
class
);
LockBatchRequestBody
requestBody
=
LockBatchRequestBody
.
decode
(
request
.
getBody
(),
LockBatchRequestBody
.
class
);
Set
<
MessageQueue
>
lockOKMQSet
=
this
.
brokerController
.
getRebalanceLockManager
().
tryLockBatch
(
//
Set
<
MessageQueue
>
lockOKMQSet
=
this
.
brokerController
.
getRebalanceLockManager
().
tryLockBatch
(
requestBody
.
getConsumerGroup
(),
//
requestBody
.
getConsumerGroup
(),
requestBody
.
getMqSet
(),
//
requestBody
.
getMqSet
(),
requestBody
.
getClientId
());
requestBody
.
getClientId
());
LockBatchResponseBody
responseBody
=
new
LockBatchResponseBody
();
LockBatchResponseBody
responseBody
=
new
LockBatchResponseBody
();
...
@@ -450,9 +451,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -450,9 +451,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
UnlockBatchRequestBody
requestBody
=
UnlockBatchRequestBody
.
decode
(
request
.
getBody
(),
UnlockBatchRequestBody
.
class
);
UnlockBatchRequestBody
requestBody
=
UnlockBatchRequestBody
.
decode
(
request
.
getBody
(),
UnlockBatchRequestBody
.
class
);
this
.
brokerController
.
getRebalanceLockManager
().
unlockBatch
(
//
this
.
brokerController
.
getRebalanceLockManager
().
unlockBatch
(
requestBody
.
getConsumerGroup
(),
//
requestBody
.
getConsumerGroup
(),
requestBody
.
getMqSet
(),
//
requestBody
.
getMqSet
(),
requestBody
.
getClientId
());
requestBody
.
getClientId
());
response
.
setCode
(
ResponseCode
.
SUCCESS
);
response
.
setCode
(
ResponseCode
.
SUCCESS
);
...
@@ -657,14 +658,12 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -657,14 +658,12 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
continue
;
continue
;
}
}
/**
*/
{
{
SubscriptionData
findSubscriptionData
=
SubscriptionData
findSubscriptionData
=
this
.
brokerController
.
getConsumerManager
().
findSubscriptionData
(
requestHeader
.
getConsumerGroup
(),
topic
);
this
.
brokerController
.
getConsumerManager
().
findSubscriptionData
(
requestHeader
.
getConsumerGroup
(),
topic
);
if
(
null
==
findSubscriptionData
//
if
(
null
==
findSubscriptionData
&&
this
.
brokerController
.
getConsumerManager
().
findSubscriptionDataCount
(
requestHeader
.
getConsumerGroup
())
>
0
)
{
&&
this
.
brokerController
.
getConsumerManager
().
findSubscriptionDataCount
(
requestHeader
.
getConsumerGroup
())
>
0
)
{
log
.
warn
(
"consumeStats, the consumer group[{}], topic[{}] not exist"
,
requestHeader
.
getConsumerGroup
(),
topic
);
log
.
warn
(
"consumeStats, the consumer group[{}], topic[{}] not exist"
,
requestHeader
.
getConsumerGroup
(),
topic
);
continue
;
continue
;
...
@@ -683,9 +682,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -683,9 +682,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
if
(
brokerOffset
<
0
)
if
(
brokerOffset
<
0
)
brokerOffset
=
0
;
brokerOffset
=
0
;
long
consumerOffset
=
this
.
brokerController
.
getConsumerOffsetManager
().
queryOffset
(
//
long
consumerOffset
=
this
.
brokerController
.
getConsumerOffsetManager
().
queryOffset
(
requestHeader
.
getConsumerGroup
(),
//
requestHeader
.
getConsumerGroup
(),
topic
,
//
topic
,
i
);
i
);
if
(
consumerOffset
<
0
)
if
(
consumerOffset
<
0
)
consumerOffset
=
0
;
consumerOffset
=
0
;
...
@@ -925,9 +924,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -925,9 +924,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return
response
;
return
response
;
}
}
/**
*/
private
RemotingCommand
getConsumerRunningInfo
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
)
throws
RemotingCommandException
{
private
RemotingCommand
getConsumerRunningInfo
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
)
throws
RemotingCommandException
{
final
GetConsumerRunningInfoRequestHeader
requestHeader
=
final
GetConsumerRunningInfoRequestHeader
requestHeader
=
(
GetConsumerRunningInfoRequestHeader
)
request
.
decodeCommandCustomHeader
(
GetConsumerRunningInfoRequestHeader
.
class
);
(
GetConsumerRunningInfoRequestHeader
)
request
.
decodeCommandCustomHeader
(
GetConsumerRunningInfoRequestHeader
.
class
);
...
@@ -1007,9 +1004,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -1007,9 +1004,7 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
continue
;
continue
;
}
}
/**
*/
if
(!
requestHeader
.
isOffline
())
{
if
(!
requestHeader
.
isOffline
())
{
SubscriptionData
findSubscriptionData
=
SubscriptionData
findSubscriptionData
=
...
@@ -1107,13 +1102,11 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -1107,13 +1102,11 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
if
(
isOrder
&&
!
topicConfig
.
isOrder
())
{
if
(
isOrder
&&
!
topicConfig
.
isOrder
())
{
continue
;
continue
;
}
}
/**
*/
{
{
SubscriptionData
findSubscriptionData
=
this
.
brokerController
.
getConsumerManager
().
findSubscriptionData
(
group
,
topic
);
SubscriptionData
findSubscriptionData
=
this
.
brokerController
.
getConsumerManager
().
findSubscriptionData
(
group
,
topic
);
if
(
null
==
findSubscriptionData
//
if
(
null
==
findSubscriptionData
&&
this
.
brokerController
.
getConsumerManager
().
findSubscriptionDataCount
(
group
)
>
0
)
{
&&
this
.
brokerController
.
getConsumerManager
().
findSubscriptionDataCount
(
group
)
>
0
)
{
log
.
warn
(
"consumeStats, the consumer group[{}], topic[{}] not exist"
,
group
,
topic
);
log
.
warn
(
"consumeStats, the consumer group[{}], topic[{}] not exist"
,
group
,
topic
);
continue
;
continue
;
...
@@ -1129,9 +1122,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -1129,9 +1122,9 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
long
brokerOffset
=
this
.
brokerController
.
getMessageStore
().
getMaxOffsetInQueue
(
topic
,
i
);
long
brokerOffset
=
this
.
brokerController
.
getMessageStore
().
getMaxOffsetInQueue
(
topic
,
i
);
if
(
brokerOffset
<
0
)
if
(
brokerOffset
<
0
)
brokerOffset
=
0
;
brokerOffset
=
0
;
long
consumerOffset
=
this
.
brokerController
.
getConsumerOffsetManager
().
queryOffset
(
//
long
consumerOffset
=
this
.
brokerController
.
getConsumerOffsetManager
().
queryOffset
(
group
,
//
group
,
topic
,
//
topic
,
i
);
i
);
if
(
consumerOffset
<
0
)
if
(
consumerOffset
<
0
)
consumerOffset
=
0
;
consumerOffset
=
0
;
...
@@ -1215,10 +1208,10 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -1215,10 +1208,10 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
return
runtimeInfo
;
return
runtimeInfo
;
}
}
private
RemotingCommand
callConsumer
(
//
private
RemotingCommand
callConsumer
(
final
int
requestCode
,
//
final
int
requestCode
,
final
RemotingCommand
request
,
//
final
RemotingCommand
request
,
final
String
consumerGroup
,
//
final
String
consumerGroup
,
final
String
clientId
)
throws
RemotingCommandException
{
final
String
clientId
)
throws
RemotingCommandException
{
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
ClientChannelInfo
clientChannelInfo
=
this
.
brokerController
.
getConsumerManager
().
findChannel
(
consumerGroup
,
clientId
);
ClientChannelInfo
clientChannelInfo
=
this
.
brokerController
.
getConsumerManager
().
findChannel
(
consumerGroup
,
clientId
);
...
@@ -1231,8 +1224,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
...
@@ -1231,8 +1224,8 @@ public class AdminBrokerProcessor implements NettyRequestProcessor {
if
(
clientChannelInfo
.
getVersion
()
<
MQVersion
.
Version
.
V3_1_8_SNAPSHOT
.
ordinal
())
{
if
(
clientChannelInfo
.
getVersion
()
<
MQVersion
.
Version
.
V3_1_8_SNAPSHOT
.
ordinal
())
{
response
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
);
response
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
);
response
.
setRemark
(
String
.
format
(
"The Consumer <%s> Version <%s> too low to finish, please upgrade it to V3_1_8_SNAPSHOT"
,
//
response
.
setRemark
(
String
.
format
(
"The Consumer <%s> Version <%s> too low to finish, please upgrade it to V3_1_8_SNAPSHOT"
,
clientId
,
//
clientId
,
MQVersion
.
getVersionDesc
(
clientChannelInfo
.
getVersion
())));
MQVersion
.
getVersionDesc
(
clientChannelInfo
.
getVersion
())));
return
response
;
return
response
;
}
}
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/PullMessageProcessor.java
浏览文件 @
7f96008c
...
@@ -160,7 +160,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
...
@@ -160,7 +160,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
assert
consumerFilterData
!=
null
;
assert
consumerFilterData
!=
null
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
warn
(
"Parse the consumer's subscription[{}] failed, group: {}"
,
requestHeader
.
getSubscription
(),
//
log
.
warn
(
"Parse the consumer's subscription[{}] failed, group: {}"
,
requestHeader
.
getSubscription
(),
requestHeader
.
getConsumerGroup
());
requestHeader
.
getConsumerGroup
());
response
.
setCode
(
ResponseCode
.
SUBSCRIPTION_PARSE_FAILED
);
response
.
setCode
(
ResponseCode
.
SUBSCRIPTION_PARSE_FAILED
);
response
.
setRemark
(
"parse the consumer's subscription failed"
);
response
.
setRemark
(
"parse the consumer's subscription failed"
);
...
@@ -176,7 +176,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
...
@@ -176,7 +176,7 @@ public class PullMessageProcessor implements NettyRequestProcessor {
return
response
;
return
response
;
}
}
if
(!
subscriptionGroupConfig
.
isConsumeBroadcastEnable
()
//
if
(!
subscriptionGroupConfig
.
isConsumeBroadcastEnable
()
&&
consumerGroupInfo
.
getMessageModel
()
==
MessageModel
.
BROADCASTING
)
{
&&
consumerGroupInfo
.
getMessageModel
()
==
MessageModel
.
BROADCASTING
)
{
response
.
setCode
(
ResponseCode
.
NO_PERMISSION
);
response
.
setCode
(
ResponseCode
.
NO_PERMISSION
);
response
.
setRemark
(
"the consumer group["
+
requestHeader
.
getConsumerGroup
()
+
"] can not consume by broadcast way"
);
response
.
setRemark
(
"the consumer group["
+
requestHeader
.
getConsumerGroup
()
+
"] can not consume by broadcast way"
);
...
@@ -285,12 +285,12 @@ public class PullMessageProcessor implements NettyRequestProcessor {
...
@@ -285,12 +285,12 @@ public class PullMessageProcessor implements NettyRequestProcessor {
response
.
setCode
(
ResponseCode
.
PULL_OFFSET_MOVED
);
response
.
setCode
(
ResponseCode
.
PULL_OFFSET_MOVED
);
// XXX: warn and notify me
// XXX: warn and notify me
log
.
info
(
"the broker store no queue data, fix the request offset {} to {}, Topic: {} QueueId: {} Consumer Group: {}"
,
//
log
.
info
(
"the broker store no queue data, fix the request offset {} to {}, Topic: {} QueueId: {} Consumer Group: {}"
,
requestHeader
.
getQueueOffset
(),
//
requestHeader
.
getQueueOffset
(),
getMessageResult
.
getNextBeginOffset
(),
//
getMessageResult
.
getNextBeginOffset
(),
requestHeader
.
getTopic
(),
//
requestHeader
.
getTopic
(),
requestHeader
.
getQueueId
(),
//
requestHeader
.
getQueueId
(),
requestHeader
.
getConsumerGroup
()
//
requestHeader
.
getConsumerGroup
()
);
);
}
else
{
}
else
{
response
.
setCode
(
ResponseCode
.
PULL_NOT_FOUND
);
response
.
setCode
(
ResponseCode
.
PULL_NOT_FOUND
);
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
浏览文件 @
7f96008c
...
@@ -139,9 +139,9 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
...
@@ -139,9 +139,9 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
topicSysFlag
=
TopicSysFlag
.
buildSysFlag
(
false
,
true
);
topicSysFlag
=
TopicSysFlag
.
buildSysFlag
(
false
,
true
);
}
}
TopicConfig
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
//
TopicConfig
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
//
newTopic
,
subscriptionGroupConfig
.
getRetryQueueNums
(),
//
subscriptionGroupConfig
.
getRetryQueueNums
(),
PermName
.
PERM_WRITE
|
PermName
.
PERM_READ
,
topicSysFlag
);
PermName
.
PERM_WRITE
|
PermName
.
PERM_READ
,
topicSysFlag
);
if
(
null
==
topicConfig
)
{
if
(
null
==
topicConfig
)
{
response
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
);
response
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
);
...
@@ -175,13 +175,13 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
...
@@ -175,13 +175,13 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
maxReconsumeTimes
=
requestHeader
.
getMaxReconsumeTimes
();
maxReconsumeTimes
=
requestHeader
.
getMaxReconsumeTimes
();
}
}
if
(
msgExt
.
getReconsumeTimes
()
>=
maxReconsumeTimes
//
if
(
msgExt
.
getReconsumeTimes
()
>=
maxReconsumeTimes
||
delayLevel
<
0
)
{
||
delayLevel
<
0
)
{
newTopic
=
MixAll
.
getDLQTopic
(
requestHeader
.
getGroup
());
newTopic
=
MixAll
.
getDLQTopic
(
requestHeader
.
getGroup
());
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
DLQ_NUMS_PER_GROUP
;
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
DLQ_NUMS_PER_GROUP
;
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
//
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
DLQ_NUMS_PER_GROUP
,
//
DLQ_NUMS_PER_GROUP
,
PermName
.
PERM_WRITE
,
0
PermName
.
PERM_WRITE
,
0
);
);
if
(
null
==
topicConfig
)
{
if
(
null
==
topicConfig
)
{
...
@@ -268,8 +268,8 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
...
@@ -268,8 +268,8 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
if
(
reconsumeTimes
>=
maxReconsumeTimes
)
{
if
(
reconsumeTimes
>=
maxReconsumeTimes
)
{
newTopic
=
MixAll
.
getDLQTopic
(
groupName
);
newTopic
=
MixAll
.
getDLQTopic
(
groupName
);
int
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
DLQ_NUMS_PER_GROUP
;
int
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
DLQ_NUMS_PER_GROUP
;
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
//
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
DLQ_NUMS_PER_GROUP
,
//
DLQ_NUMS_PER_GROUP
,
PermName
.
PERM_WRITE
,
0
PermName
.
PERM_WRITE
,
0
);
);
msg
.
setTopic
(
newTopic
);
msg
.
setTopic
(
newTopic
);
...
@@ -289,9 +289,9 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
...
@@ -289,9 +289,9 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
return
true
;
return
true
;
}
}
private
RemotingCommand
sendMessage
(
final
ChannelHandlerContext
ctx
,
//
private
RemotingCommand
sendMessage
(
final
ChannelHandlerContext
ctx
,
final
RemotingCommand
request
,
//
final
RemotingCommand
request
,
final
SendMessageContext
sendMessageContext
,
//
final
SendMessageContext
sendMessageContext
,
final
SendMessageRequestHeader
requestHeader
)
throws
RemotingCommandException
{
final
SendMessageRequestHeader
requestHeader
)
throws
RemotingCommandException
{
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
SendMessageResponseHeader
.
class
);
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
SendMessageResponseHeader
.
class
);
...
@@ -464,9 +464,9 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
...
@@ -464,9 +464,9 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
}
return
response
;
return
response
;
}
}
private
RemotingCommand
sendBatchMessage
(
final
ChannelHandlerContext
ctx
,
//
private
RemotingCommand
sendBatchMessage
(
final
ChannelHandlerContext
ctx
,
final
RemotingCommand
request
,
//
final
RemotingCommand
request
,
final
SendMessageContext
sendMessageContext
,
//
final
SendMessageContext
sendMessageContext
,
final
SendMessageRequestHeader
requestHeader
)
throws
RemotingCommandException
{
final
SendMessageRequestHeader
requestHeader
)
throws
RemotingCommandException
{
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
SendMessageResponseHeader
.
class
);
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
SendMessageResponseHeader
.
class
);
...
...
broker/src/test/java/org/apache/rocketmq/broker/BrokerControllerTest.java
浏览文件 @
7f96008c
...
@@ -38,10 +38,10 @@ public class BrokerControllerTest {
...
@@ -38,10 +38,10 @@ public class BrokerControllerTest {
@Test
@Test
public
void
testBrokerRestart
()
throws
Exception
{
public
void
testBrokerRestart
()
throws
Exception
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
BrokerController
brokerController
=
new
BrokerController
(
//
BrokerController
brokerController
=
new
BrokerController
(
new
BrokerConfig
(),
//
new
BrokerConfig
(),
new
NettyServerConfig
(),
//
new
NettyServerConfig
(),
new
NettyClientConfig
(),
//
new
NettyClientConfig
(),
new
MessageStoreConfig
());
new
MessageStoreConfig
());
assertThat
(
brokerController
.
initialize
());
assertThat
(
brokerController
.
initialize
());
brokerController
.
start
();
brokerController
.
start
();
...
...
client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
浏览文件 @
7f96008c
...
@@ -52,9 +52,9 @@ public class LocalFileOffsetStore implements OffsetStore {
...
@@ -52,9 +52,9 @@ public class LocalFileOffsetStore implements OffsetStore {
public
LocalFileOffsetStore
(
MQClientInstance
mQClientFactory
,
String
groupName
)
{
public
LocalFileOffsetStore
(
MQClientInstance
mQClientFactory
,
String
groupName
)
{
this
.
mQClientFactory
=
mQClientFactory
;
this
.
mQClientFactory
=
mQClientFactory
;
this
.
groupName
=
groupName
;
this
.
groupName
=
groupName
;
this
.
storePath
=
LOCAL_OFFSET_STORE_DIR
+
File
.
separator
+
//
this
.
storePath
=
LOCAL_OFFSET_STORE_DIR
+
File
.
separator
+
this
.
mQClientFactory
.
getClientId
()
+
File
.
separator
+
//
this
.
mQClientFactory
.
getClientId
()
+
File
.
separator
+
this
.
groupName
+
File
.
separator
+
//
this
.
groupName
+
File
.
separator
+
"offsets.json"
;
"offsets.json"
;
}
}
...
@@ -217,8 +217,8 @@ public class LocalFileOffsetStore implements OffsetStore {
...
@@ -217,8 +217,8 @@ public class LocalFileOffsetStore implements OffsetStore {
OffsetSerializeWrapper
.
fromJson
(
content
,
OffsetSerializeWrapper
.
class
);
OffsetSerializeWrapper
.
fromJson
(
content
,
OffsetSerializeWrapper
.
class
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
warn
(
"readLocalOffset Exception"
,
e
);
log
.
warn
(
"readLocalOffset Exception"
,
e
);
throw
new
MQClientException
(
"readLocalOffset Exception, maybe fastjson version too low"
//
throw
new
MQClientException
(
"readLocalOffset Exception, maybe fastjson version too low"
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
LOAD_JSON_EXCEPTION
),
//
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
LOAD_JSON_EXCEPTION
),
e
);
e
);
}
}
return
offsetSerializeWrapper
;
return
offsetSerializeWrapper
;
...
...
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
浏览文件 @
7f96008c
...
@@ -204,7 +204,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
...
@@ -204,7 +204,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
MQBrokerException
,
InterruptedException
,
MQClientException
{
MQBrokerException
,
InterruptedException
,
MQClientException
{
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
if
(
null
==
findBrokerResult
)
{
if
(
null
==
findBrokerResult
)
{
// TODO Here may be heavily overhead for Name Server,need tuning
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
}
}
...
@@ -232,7 +232,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
...
@@ -232,7 +232,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
InterruptedException
,
MQClientException
{
InterruptedException
,
MQClientException
{
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
if
(
null
==
findBrokerResult
)
{
if
(
null
==
findBrokerResult
)
{
// TODO Here may be heavily overhead for Name Server,need tuning
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
浏览文件 @
7f96008c
...
@@ -159,7 +159,7 @@ public class MQAdminImpl {
...
@@ -159,7 +159,7 @@ public class MQAdminImpl {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
MQClientException
(
throw
new
MQClientException
(
"Can not find Message Queue for this topic, "
+
topic
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
MQLIST_NOT_EXIST
),
//
"Can not find Message Queue for this topic, "
+
topic
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
MQLIST_NOT_EXIST
),
e
);
e
);
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
浏览文件 @
7f96008c
...
@@ -285,32 +285,32 @@ public class MQClientAPIImpl {
...
@@ -285,32 +285,32 @@ public class MQClientAPIImpl {
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
SendResult
sendMessage
(
//
public
SendResult
sendMessage
(
final
String
addr
,
// 1
final
String
addr
,
final
String
brokerName
,
// 2
final
String
brokerName
,
final
Message
msg
,
// 3
final
Message
msg
,
final
SendMessageRequestHeader
requestHeader
,
// 4
final
SendMessageRequestHeader
requestHeader
,
final
long
timeoutMillis
,
// 5
final
long
timeoutMillis
,
final
CommunicationMode
communicationMode
,
// 6
final
CommunicationMode
communicationMode
,
final
SendMessageContext
context
,
// 7
final
SendMessageContext
context
,
final
DefaultMQProducerImpl
producer
// 8
final
DefaultMQProducerImpl
producer
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
return
sendMessage
(
addr
,
brokerName
,
msg
,
requestHeader
,
timeoutMillis
,
communicationMode
,
null
,
null
,
null
,
0
,
context
,
producer
);
return
sendMessage
(
addr
,
brokerName
,
msg
,
requestHeader
,
timeoutMillis
,
communicationMode
,
null
,
null
,
null
,
0
,
context
,
producer
);
}
}
public
SendResult
sendMessage
(
//
public
SendResult
sendMessage
(
final
String
addr
,
// 1
final
String
addr
,
final
String
brokerName
,
// 2
final
String
brokerName
,
final
Message
msg
,
// 3
final
Message
msg
,
final
SendMessageRequestHeader
requestHeader
,
// 4
final
SendMessageRequestHeader
requestHeader
,
final
long
timeoutMillis
,
// 5
final
long
timeoutMillis
,
final
CommunicationMode
communicationMode
,
// 6
final
CommunicationMode
communicationMode
,
final
SendCallback
sendCallback
,
// 7
final
SendCallback
sendCallback
,
final
TopicPublishInfo
topicPublishInfo
,
// 8
final
TopicPublishInfo
topicPublishInfo
,
final
MQClientInstance
instance
,
// 9
final
MQClientInstance
instance
,
final
int
retryTimesWhenSendFailed
,
// 10
final
int
retryTimesWhenSendFailed
,
final
SendMessageContext
context
,
// 11
final
SendMessageContext
context
,
final
DefaultMQProducerImpl
producer
// 12
final
DefaultMQProducerImpl
producer
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
null
;
RemotingCommand
request
=
null
;
if
(
sendSmartMsg
||
msg
instanceof
MessageBatch
)
{
if
(
sendSmartMsg
||
msg
instanceof
MessageBatch
)
{
...
@@ -341,31 +341,31 @@ public class MQClientAPIImpl {
...
@@ -341,31 +341,31 @@ public class MQClientAPIImpl {
return
null
;
return
null
;
}
}
private
SendResult
sendMessageSync
(
//
private
SendResult
sendMessageSync
(
final
String
addr
,
//
final
String
addr
,
final
String
brokerName
,
//
final
String
brokerName
,
final
Message
msg
,
//
final
Message
msg
,
final
long
timeoutMillis
,
//
final
long
timeoutMillis
,
final
RemotingCommand
request
//
final
RemotingCommand
request
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
addr
,
request
,
timeoutMillis
);
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
addr
,
request
,
timeoutMillis
);
assert
response
!=
null
;
assert
response
!=
null
;
return
this
.
processSendResponse
(
brokerName
,
msg
,
response
);
return
this
.
processSendResponse
(
brokerName
,
msg
,
response
);
}
}
private
void
sendMessageAsync
(
//
private
void
sendMessageAsync
(
final
String
addr
,
//
final
String
addr
,
final
String
brokerName
,
//
final
String
brokerName
,
final
Message
msg
,
//
final
Message
msg
,
final
long
timeoutMillis
,
//
final
long
timeoutMillis
,
final
RemotingCommand
request
,
//
final
RemotingCommand
request
,
final
SendCallback
sendCallback
,
//
final
SendCallback
sendCallback
,
final
TopicPublishInfo
topicPublishInfo
,
//
final
TopicPublishInfo
topicPublishInfo
,
final
MQClientInstance
instance
,
//
final
MQClientInstance
instance
,
final
int
retryTimesWhenSendFailed
,
//
final
int
retryTimesWhenSendFailed
,
final
AtomicInteger
times
,
//
final
AtomicInteger
times
,
final
SendMessageContext
context
,
//
final
SendMessageContext
context
,
final
DefaultMQProducerImpl
producer
//
final
DefaultMQProducerImpl
producer
)
throws
InterruptedException
,
RemotingException
{
)
throws
InterruptedException
,
RemotingException
{
this
.
remotingClient
.
invokeAsync
(
addr
,
request
,
timeoutMillis
,
new
InvokeCallback
()
{
this
.
remotingClient
.
invokeAsync
(
addr
,
request
,
timeoutMillis
,
new
InvokeCallback
()
{
@Override
@Override
...
@@ -380,7 +380,6 @@ public class MQClientAPIImpl {
...
@@ -380,7 +380,6 @@ public class MQClientAPIImpl {
context
.
getProducer
().
executeSendMessageHookAfter
(
context
);
context
.
getProducer
().
executeSendMessageHookAfter
(
context
);
}
}
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
//
}
}
producer
.
updateFaultItem
(
brokerName
,
System
.
currentTimeMillis
()
-
responseFuture
.
getBeginTimestamp
(),
false
);
producer
.
updateFaultItem
(
brokerName
,
System
.
currentTimeMillis
()
-
responseFuture
.
getBeginTimestamp
(),
false
);
...
@@ -428,19 +427,19 @@ public class MQClientAPIImpl {
...
@@ -428,19 +427,19 @@ public class MQClientAPIImpl {
});
});
}
}
private
void
onExceptionImpl
(
final
String
brokerName
,
//
private
void
onExceptionImpl
(
final
String
brokerName
,
final
Message
msg
,
//
final
Message
msg
,
final
long
timeoutMillis
,
//
final
long
timeoutMillis
,
final
RemotingCommand
request
,
//
final
RemotingCommand
request
,
final
SendCallback
sendCallback
,
//
final
SendCallback
sendCallback
,
final
TopicPublishInfo
topicPublishInfo
,
//
final
TopicPublishInfo
topicPublishInfo
,
final
MQClientInstance
instance
,
//
final
MQClientInstance
instance
,
final
int
timesTotal
,
//
final
int
timesTotal
,
final
AtomicInteger
curTimes
,
//
final
AtomicInteger
curTimes
,
final
Exception
e
,
//
final
Exception
e
,
final
SendMessageContext
context
,
//
final
SendMessageContext
context
,
final
boolean
needRetry
,
//
final
boolean
needRetry
,
final
DefaultMQProducerImpl
producer
// 12
final
DefaultMQProducerImpl
producer
)
{
)
{
int
tmp
=
curTimes
.
incrementAndGet
();
int
tmp
=
curTimes
.
incrementAndGet
();
if
(
needRetry
&&
tmp
<=
timesTotal
)
{
if
(
needRetry
&&
tmp
<=
timesTotal
)
{
...
@@ -485,16 +484,15 @@ public class MQClientAPIImpl {
...
@@ -485,16 +484,15 @@ public class MQClientAPIImpl {
}
}
}
}
private
SendResult
processSendResponse
(
//
private
SendResult
processSendResponse
(
final
String
brokerName
,
//
final
String
brokerName
,
final
Message
msg
,
//
final
Message
msg
,
final
RemotingCommand
response
//
final
RemotingCommand
response
)
throws
MQBrokerException
,
RemotingCommandException
{
)
throws
MQBrokerException
,
RemotingCommandException
{
switch
(
response
.
getCode
())
{
switch
(
response
.
getCode
())
{
case
ResponseCode
.
FLUSH_DISK_TIMEOUT
:
case
ResponseCode
.
FLUSH_DISK_TIMEOUT
:
case
ResponseCode
.
FLUSH_SLAVE_TIMEOUT
:
case
ResponseCode
.
FLUSH_SLAVE_TIMEOUT
:
case
ResponseCode
.
SLAVE_NOT_AVAILABLE
:
{
case
ResponseCode
.
SLAVE_NOT_AVAILABLE
:
{
// TODO LOG
}
}
case
ResponseCode
.
SUCCESS
:
{
case
ResponseCode
.
SUCCESS
:
{
SendStatus
sendStatus
=
SendStatus
.
SEND_OK
;
SendStatus
sendStatus
=
SendStatus
.
SEND_OK
;
...
@@ -553,12 +551,12 @@ public class MQClientAPIImpl {
...
@@ -553,12 +551,12 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
PullResult
pullMessage
(
//
public
PullResult
pullMessage
(
final
String
addr
,
//
final
String
addr
,
final
PullMessageRequestHeader
requestHeader
,
//
final
PullMessageRequestHeader
requestHeader
,
final
long
timeoutMillis
,
//
final
long
timeoutMillis
,
final
CommunicationMode
communicationMode
,
//
final
CommunicationMode
communicationMode
,
final
PullCallback
pullCallback
//
final
PullCallback
pullCallback
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
PULL_MESSAGE
,
requestHeader
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
PULL_MESSAGE
,
requestHeader
);
...
@@ -579,11 +577,11 @@ public class MQClientAPIImpl {
...
@@ -579,11 +577,11 @@ public class MQClientAPIImpl {
return
null
;
return
null
;
}
}
private
void
pullMessageAsync
(
//
private
void
pullMessageAsync
(
final
String
addr
,
// 1
final
String
addr
,
final
RemotingCommand
request
,
//
final
RemotingCommand
request
,
final
long
timeoutMillis
,
//
final
long
timeoutMillis
,
final
PullCallback
pullCallback
//
final
PullCallback
pullCallback
)
throws
RemotingException
,
InterruptedException
{
)
throws
RemotingException
,
InterruptedException
{
this
.
remotingClient
.
invokeAsync
(
addr
,
request
,
timeoutMillis
,
new
InvokeCallback
()
{
this
.
remotingClient
.
invokeAsync
(
addr
,
request
,
timeoutMillis
,
new
InvokeCallback
()
{
@Override
@Override
...
@@ -611,10 +609,10 @@ public class MQClientAPIImpl {
...
@@ -611,10 +609,10 @@ public class MQClientAPIImpl {
});
});
}
}
private
PullResult
pullMessageSync
(
//
private
PullResult
pullMessageSync
(
final
String
addr
,
// 1
final
String
addr
,
final
RemotingCommand
request
,
// 2
final
RemotingCommand
request
,
final
long
timeoutMillis
// 3
final
long
timeoutMillis
)
throws
RemotingException
,
InterruptedException
,
MQBrokerException
{
)
throws
RemotingException
,
InterruptedException
,
MQBrokerException
{
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
addr
,
request
,
timeoutMillis
);
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
addr
,
request
,
timeoutMillis
);
assert
response
!=
null
;
assert
response
!=
null
;
...
@@ -720,9 +718,9 @@ public class MQClientAPIImpl {
...
@@ -720,9 +718,9 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
List
<
String
>
getConsumerIdListByGroup
(
//
public
List
<
String
>
getConsumerIdListByGroup
(
final
String
addr
,
//
final
String
addr
,
final
String
consumerGroup
,
//
final
String
consumerGroup
,
final
long
timeoutMillis
)
throws
RemotingConnectException
,
RemotingSendRequestException
,
RemotingTimeoutException
,
final
long
timeoutMillis
)
throws
RemotingConnectException
,
RemotingSendRequestException
,
RemotingTimeoutException
,
MQBrokerException
,
InterruptedException
{
MQBrokerException
,
InterruptedException
{
GetConsumerListByGroupRequestHeader
requestHeader
=
new
GetConsumerListByGroupRequestHeader
();
GetConsumerListByGroupRequestHeader
requestHeader
=
new
GetConsumerListByGroupRequestHeader
();
...
@@ -796,10 +794,10 @@ public class MQClientAPIImpl {
...
@@ -796,10 +794,10 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
long
queryConsumerOffset
(
//
public
long
queryConsumerOffset
(
final
String
addr
,
//
final
String
addr
,
final
QueryConsumerOffsetRequestHeader
requestHeader
,
//
final
QueryConsumerOffsetRequestHeader
requestHeader
,
final
long
timeoutMillis
//
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
QUERY_CONSUMER_OFFSET
,
requestHeader
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
QUERY_CONSUMER_OFFSET
,
requestHeader
);
...
@@ -820,10 +818,10 @@ public class MQClientAPIImpl {
...
@@ -820,10 +818,10 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
void
updateConsumerOffset
(
//
public
void
updateConsumerOffset
(
final
String
addr
,
//
final
String
addr
,
final
UpdateConsumerOffsetRequestHeader
requestHeader
,
//
final
UpdateConsumerOffsetRequestHeader
requestHeader
,
final
long
timeoutMillis
//
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
UPDATE_CONSUMER_OFFSET
,
requestHeader
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
UPDATE_CONSUMER_OFFSET
,
requestHeader
);
...
@@ -841,10 +839,10 @@ public class MQClientAPIImpl {
...
@@ -841,10 +839,10 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
void
updateConsumerOffsetOneway
(
//
public
void
updateConsumerOffsetOneway
(
final
String
addr
,
//
final
String
addr
,
final
UpdateConsumerOffsetRequestHeader
requestHeader
,
//
final
UpdateConsumerOffsetRequestHeader
requestHeader
,
final
long
timeoutMillis
//
final
long
timeoutMillis
)
throws
RemotingConnectException
,
RemotingTooMuchRequestException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
)
throws
RemotingConnectException
,
RemotingTooMuchRequestException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
InterruptedException
{
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
UPDATE_CONSUMER_OFFSET
,
requestHeader
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
UPDATE_CONSUMER_OFFSET
,
requestHeader
);
...
@@ -852,10 +850,10 @@ public class MQClientAPIImpl {
...
@@ -852,10 +850,10 @@ public class MQClientAPIImpl {
this
.
remotingClient
.
invokeOneway
(
MixAll
.
brokerVIPChannel
(
this
.
clientConfig
.
isVipChannelEnabled
(),
addr
),
request
,
timeoutMillis
);
this
.
remotingClient
.
invokeOneway
(
MixAll
.
brokerVIPChannel
(
this
.
clientConfig
.
isVipChannelEnabled
(),
addr
),
request
,
timeoutMillis
);
}
}
public
int
sendHearbeat
(
//
public
int
sendHearbeat
(
final
String
addr
,
//
final
String
addr
,
final
HeartbeatData
heartbeatData
,
//
final
HeartbeatData
heartbeatData
,
final
long
timeoutMillis
//
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
HEART_BEAT
,
null
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
HEART_BEAT
,
null
);
...
@@ -873,12 +871,12 @@ public class MQClientAPIImpl {
...
@@ -873,12 +871,12 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
void
unregisterClient
(
//
public
void
unregisterClient
(
final
String
addr
,
//
final
String
addr
,
final
String
clientID
,
//
final
String
clientID
,
final
String
producerGroup
,
//
final
String
producerGroup
,
final
String
consumerGroup
,
//
final
String
consumerGroup
,
final
long
timeoutMillis
//
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
final
UnregisterClientRequestHeader
requestHeader
=
new
UnregisterClientRequestHeader
();
final
UnregisterClientRequestHeader
requestHeader
=
new
UnregisterClientRequestHeader
();
requestHeader
.
setClientID
(
clientID
);
requestHeader
.
setClientID
(
clientID
);
...
@@ -899,11 +897,11 @@ public class MQClientAPIImpl {
...
@@ -899,11 +897,11 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
void
endTransactionOneway
(
//
public
void
endTransactionOneway
(
final
String
addr
,
//
final
String
addr
,
final
EndTransactionRequestHeader
requestHeader
,
//
final
EndTransactionRequestHeader
requestHeader
,
final
String
remark
,
//
final
String
remark
,
final
long
timeoutMillis
//
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
END_TRANSACTION
,
requestHeader
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
END_TRANSACTION
,
requestHeader
);
...
@@ -965,9 +963,9 @@ public class MQClientAPIImpl {
...
@@ -965,9 +963,9 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
Set
<
MessageQueue
>
lockBatchMQ
(
//
public
Set
<
MessageQueue
>
lockBatchMQ
(
final
String
addr
,
//
final
String
addr
,
final
LockBatchRequestBody
requestBody
,
//
final
LockBatchRequestBody
requestBody
,
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
LOCK_BATCH_MQ
,
null
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
LOCK_BATCH_MQ
,
null
);
...
@@ -987,11 +985,11 @@ public class MQClientAPIImpl {
...
@@ -987,11 +985,11 @@ public class MQClientAPIImpl {
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQBrokerException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
void
unlockBatchMQ
(
//
public
void
unlockBatchMQ
(
final
String
addr
,
//
final
String
addr
,
final
UnlockBatchRequestBody
requestBody
,
//
final
UnlockBatchRequestBody
requestBody
,
final
long
timeoutMillis
,
//
final
long
timeoutMillis
,
final
boolean
oneway
//
final
boolean
oneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
UNLOCK_BATCH_MQ
,
null
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
UNLOCK_BATCH_MQ
,
null
);
...
@@ -1213,7 +1211,7 @@ public class MQClientAPIImpl {
...
@@ -1213,7 +1211,7 @@ public class MQClientAPIImpl {
if
(
allowTopicNotExist
&&
!
topic
.
equals
(
MixAll
.
DEFAULT_TOPIC
))
{
if
(
allowTopicNotExist
&&
!
topic
.
equals
(
MixAll
.
DEFAULT_TOPIC
))
{
log
.
warn
(
"get Topic [{}] RouteInfoFromNameServer is not exist value"
,
topic
);
log
.
warn
(
"get Topic [{}] RouteInfoFromNameServer is not exist value"
,
topic
);
}
}
// TODO :- Log when if condition is not satisfied
break
;
break
;
}
}
case
ResponseCode
.
SUCCESS
:
{
case
ResponseCode
.
SUCCESS
:
{
...
@@ -1566,12 +1564,12 @@ public class MQClientAPIImpl {
...
@@ -1566,12 +1564,12 @@ public class MQClientAPIImpl {
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
void
registerMessageFilterClass
(
final
String
addr
,
//
public
void
registerMessageFilterClass
(
final
String
addr
,
final
String
consumerGroup
,
//
final
String
consumerGroup
,
final
String
topic
,
//
final
String
topic
,
final
String
className
,
//
final
String
className
,
final
int
classCRC
,
//
final
int
classCRC
,
final
byte
[]
classBody
,
//
final
byte
[]
classBody
,
final
long
timeoutMillis
)
throws
RemotingConnectException
,
RemotingSendRequestException
,
RemotingTimeoutException
,
final
long
timeoutMillis
)
throws
RemotingConnectException
,
RemotingSendRequestException
,
RemotingTimeoutException
,
InterruptedException
,
MQBrokerException
{
InterruptedException
,
MQBrokerException
{
RegisterMessageFilterClassRequestHeader
requestHeader
=
new
RegisterMessageFilterClassRequestHeader
();
RegisterMessageFilterClassRequestHeader
requestHeader
=
new
RegisterMessageFilterClassRequestHeader
();
...
@@ -1706,10 +1704,10 @@ public class MQClientAPIImpl {
...
@@ -1706,10 +1704,10 @@ public class MQClientAPIImpl {
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
}
}
public
ConsumeMessageDirectlyResult
consumeMessageDirectly
(
final
String
addr
,
//
public
ConsumeMessageDirectlyResult
consumeMessageDirectly
(
final
String
addr
,
String
consumerGroup
,
//
String
consumerGroup
,
String
clientId
,
//
String
clientId
,
String
msgId
,
//
String
msgId
,
final
long
timeoutMillis
)
throws
RemotingException
,
MQClientException
,
InterruptedException
{
final
long
timeoutMillis
)
throws
RemotingException
,
MQClientException
,
InterruptedException
{
ConsumeMessageDirectlyResultRequestHeader
requestHeader
=
new
ConsumeMessageDirectlyResultRequestHeader
();
ConsumeMessageDirectlyResultRequestHeader
requestHeader
=
new
ConsumeMessageDirectlyResultRequestHeader
();
requestHeader
.
setConsumerGroup
(
consumerGroup
);
requestHeader
.
setConsumerGroup
(
consumerGroup
);
...
@@ -1912,7 +1910,6 @@ public class MQClientAPIImpl {
...
@@ -1912,7 +1910,6 @@ public class MQClientAPIImpl {
public
Set
<
String
>
getClusterList
(
String
topic
,
public
Set
<
String
>
getClusterList
(
String
topic
,
long
timeoutMillis
)
throws
MQClientException
,
RemotingConnectException
,
long
timeoutMillis
)
throws
MQClientException
,
RemotingConnectException
,
RemotingSendRequestException
,
RemotingTimeoutException
,
InterruptedException
{
RemotingSendRequestException
,
RemotingTimeoutException
,
InterruptedException
{
// todo:jodie
return
Collections
.
EMPTY_SET
;
return
Collections
.
EMPTY_SET
;
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageConcurrentlyService.java
浏览文件 @
7f96008c
...
@@ -69,12 +69,12 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -69,12 +69,12 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
this
.
consumerGroup
=
this
.
defaultMQPushConsumer
.
getConsumerGroup
();
this
.
consumerGroup
=
this
.
defaultMQPushConsumer
.
getConsumerGroup
();
this
.
consumeRequestQueue
=
new
LinkedBlockingQueue
<
Runnable
>();
this
.
consumeRequestQueue
=
new
LinkedBlockingQueue
<
Runnable
>();
this
.
consumeExecutor
=
new
ThreadPoolExecutor
(
//
this
.
consumeExecutor
=
new
ThreadPoolExecutor
(
this
.
defaultMQPushConsumer
.
getConsumeThreadMin
(),
//
this
.
defaultMQPushConsumer
.
getConsumeThreadMin
(),
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
(),
//
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
(),
1000
*
60
,
//
1000
*
60
,
TimeUnit
.
MILLISECONDS
,
//
TimeUnit
.
MILLISECONDS
,
this
.
consumeRequestQueue
,
//
this
.
consumeRequestQueue
,
new
ThreadFactoryImpl
(
"ConsumeMessageThread_"
));
new
ThreadFactoryImpl
(
"ConsumeMessageThread_"
));
this
.
scheduledExecutorService
=
Executors
.
newSingleThreadScheduledExecutor
(
new
ThreadFactoryImpl
(
"ConsumeMessageScheduledThread_"
));
this
.
scheduledExecutorService
=
Executors
.
newSingleThreadScheduledExecutor
(
new
ThreadFactoryImpl
(
"ConsumeMessageScheduledThread_"
));
...
@@ -100,8 +100,8 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -100,8 +100,8 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
@Override
@Override
public
void
updateCorePoolSize
(
int
corePoolSize
)
{
public
void
updateCorePoolSize
(
int
corePoolSize
)
{
if
(
corePoolSize
>
0
//
if
(
corePoolSize
>
0
&&
corePoolSize
<=
Short
.
MAX_VALUE
//
&&
corePoolSize
<=
Short
.
MAX_VALUE
&&
corePoolSize
<
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
())
{
&&
corePoolSize
<
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
())
{
this
.
consumeExecutor
.
setCorePoolSize
(
corePoolSize
);
this
.
consumeExecutor
.
setCorePoolSize
(
corePoolSize
);
}
}
...
@@ -115,11 +115,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -115,11 +115,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
// this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
// this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
// + 1);
// + 1);
// }
// }
//
// log.info("incCorePoolSize Concurrently from {} to {}, ConsumerGroup:
// log.info("incCorePoolSize Concurrently from {} to {}, ConsumerGroup:
// {}",
//
// {}",
// corePoolSize,
//
// corePoolSize,
// this.consumeExecutor.getCorePoolSize(),
//
// this.consumeExecutor.getCorePoolSize(),
// this.consumerGroup);
// this.consumerGroup);
}
}
...
@@ -131,11 +130,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -131,11 +130,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
// this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
// this.consumeExecutor.setCorePoolSize(this.consumeExecutor.getCorePoolSize()
// - 1);
// - 1);
// }
// }
//
// log.info("decCorePoolSize Concurrently from {} to {}, ConsumerGroup:
// log.info("decCorePoolSize Concurrently from {} to {}, ConsumerGroup:
// {}",
//
// {}",
// corePoolSize,
//
// corePoolSize,
// this.consumeExecutor.getCorePoolSize(),
//
// this.consumeExecutor.getCorePoolSize(),
// this.consumerGroup);
// this.consumerGroup);
}
}
...
@@ -185,10 +183,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -185,10 +183,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
result
.
setConsumeResult
(
CMResult
.
CR_THROW_EXCEPTION
);
result
.
setConsumeResult
(
CMResult
.
CR_THROW_EXCEPTION
);
result
.
setRemark
(
RemotingHelper
.
exceptionSimpleDesc
(
e
));
result
.
setRemark
(
RemotingHelper
.
exceptionSimpleDesc
(
e
));
log
.
warn
(
String
.
format
(
"consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s"
,
//
log
.
warn
(
String
.
format
(
"consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s"
,
RemotingHelper
.
exceptionSimpleDesc
(
e
),
//
RemotingHelper
.
exceptionSimpleDesc
(
e
),
ConsumeMessageConcurrentlyService
.
this
.
consumerGroup
,
//
ConsumeMessageConcurrentlyService
.
this
.
consumerGroup
,
msgs
,
//
msgs
,
mq
),
e
);
mq
),
e
);
}
}
...
@@ -200,10 +198,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -200,10 +198,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
}
}
@Override
@Override
public
void
submitConsumeRequest
(
//
public
void
submitConsumeRequest
(
final
List
<
MessageExt
>
msgs
,
//
final
List
<
MessageExt
>
msgs
,
final
ProcessQueue
processQueue
,
//
final
ProcessQueue
processQueue
,
final
MessageQueue
messageQueue
,
//
final
MessageQueue
messageQueue
,
final
boolean
dispatchToConsume
)
{
final
boolean
dispatchToConsume
)
{
final
int
consumeBatchSize
=
this
.
defaultMQPushConsumer
.
getConsumeMessageBatchMaxSize
();
final
int
consumeBatchSize
=
this
.
defaultMQPushConsumer
.
getConsumeMessageBatchMaxSize
();
if
(
msgs
.
size
()
<=
consumeBatchSize
)
{
if
(
msgs
.
size
()
<=
consumeBatchSize
)
{
...
@@ -258,10 +256,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -258,10 +256,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
}
}
}
}
public
void
processConsumeResult
(
//
public
void
processConsumeResult
(
final
ConsumeConcurrentlyStatus
status
,
//
final
ConsumeConcurrentlyStatus
status
,
final
ConsumeConcurrentlyContext
context
,
//
final
ConsumeConcurrentlyContext
context
,
final
ConsumeRequest
consumeRequest
//
final
ConsumeRequest
consumeRequest
)
{
)
{
int
ackIndex
=
context
.
getAckIndex
();
int
ackIndex
=
context
.
getAckIndex
();
...
@@ -338,10 +336,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -338,10 +336,10 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
return
false
;
return
false
;
}
}
private
void
submitConsumeRequestLater
(
//
private
void
submitConsumeRequestLater
(
final
List
<
MessageExt
>
msgs
,
//
final
List
<
MessageExt
>
msgs
,
final
ProcessQueue
processQueue
,
//
final
ProcessQueue
processQueue
,
final
MessageQueue
messageQueue
//
final
MessageQueue
messageQueue
)
{
)
{
this
.
scheduledExecutorService
.
schedule
(
new
Runnable
()
{
this
.
scheduledExecutorService
.
schedule
(
new
Runnable
()
{
...
@@ -353,7 +351,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -353,7 +351,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
},
5000
,
TimeUnit
.
MILLISECONDS
);
},
5000
,
TimeUnit
.
MILLISECONDS
);
}
}
private
void
submitConsumeRequestLater
(
final
ConsumeRequest
consumeRequest
//
private
void
submitConsumeRequestLater
(
final
ConsumeRequest
consumeRequest
)
{
)
{
this
.
scheduledExecutorService
.
schedule
(
new
Runnable
()
{
this
.
scheduledExecutorService
.
schedule
(
new
Runnable
()
{
...
@@ -419,7 +417,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
...
@@ -419,7 +417,7 @@ public class ConsumeMessageConcurrentlyService implements ConsumeMessageService
status
=
listener
.
consumeMessage
(
Collections
.
unmodifiableList
(
msgs
),
context
);
status
=
listener
.
consumeMessage
(
Collections
.
unmodifiableList
(
msgs
),
context
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
log
.
warn
(
"consumeMessage exception: {} Group: {} Msgs: {} MQ: {}"
,
log
.
warn
(
"consumeMessage exception: {} Group: {} Msgs: {} MQ: {}"
,
RemotingHelper
.
exceptionSimpleDesc
(
e
),
//
RemotingHelper
.
exceptionSimpleDesc
(
e
),
ConsumeMessageConcurrentlyService
.
this
.
consumerGroup
,
ConsumeMessageConcurrentlyService
.
this
.
consumerGroup
,
msgs
,
msgs
,
messageQueue
);
messageQueue
);
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageOrderlyService.java
浏览文件 @
7f96008c
...
@@ -70,12 +70,12 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -70,12 +70,12 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
this
.
consumerGroup
=
this
.
defaultMQPushConsumer
.
getConsumerGroup
();
this
.
consumerGroup
=
this
.
defaultMQPushConsumer
.
getConsumerGroup
();
this
.
consumeRequestQueue
=
new
LinkedBlockingQueue
<
Runnable
>();
this
.
consumeRequestQueue
=
new
LinkedBlockingQueue
<
Runnable
>();
this
.
consumeExecutor
=
new
ThreadPoolExecutor
(
//
this
.
consumeExecutor
=
new
ThreadPoolExecutor
(
this
.
defaultMQPushConsumer
.
getConsumeThreadMin
(),
//
this
.
defaultMQPushConsumer
.
getConsumeThreadMin
(),
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
(),
//
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
(),
1000
*
60
,
//
1000
*
60
,
TimeUnit
.
MILLISECONDS
,
//
TimeUnit
.
MILLISECONDS
,
this
.
consumeRequestQueue
,
//
this
.
consumeRequestQueue
,
new
ThreadFactoryImpl
(
"ConsumeMessageThread_"
));
new
ThreadFactoryImpl
(
"ConsumeMessageThread_"
));
this
.
scheduledExecutorService
=
Executors
.
newSingleThreadScheduledExecutor
(
new
ThreadFactoryImpl
(
"ConsumeMessageScheduledThread_"
));
this
.
scheduledExecutorService
=
Executors
.
newSingleThreadScheduledExecutor
(
new
ThreadFactoryImpl
(
"ConsumeMessageScheduledThread_"
));
...
@@ -107,8 +107,8 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -107,8 +107,8 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
@Override
@Override
public
void
updateCorePoolSize
(
int
corePoolSize
)
{
public
void
updateCorePoolSize
(
int
corePoolSize
)
{
if
(
corePoolSize
>
0
//
if
(
corePoolSize
>
0
&&
corePoolSize
<=
Short
.
MAX_VALUE
//
&&
corePoolSize
<=
Short
.
MAX_VALUE
&&
corePoolSize
<
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
())
{
&&
corePoolSize
<
this
.
defaultMQPushConsumer
.
getConsumeThreadMax
())
{
this
.
consumeExecutor
.
setCorePoolSize
(
corePoolSize
);
this
.
consumeExecutor
.
setCorePoolSize
(
corePoolSize
);
}
}
...
@@ -171,10 +171,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -171,10 +171,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
result
.
setConsumeResult
(
CMResult
.
CR_THROW_EXCEPTION
);
result
.
setConsumeResult
(
CMResult
.
CR_THROW_EXCEPTION
);
result
.
setRemark
(
RemotingHelper
.
exceptionSimpleDesc
(
e
));
result
.
setRemark
(
RemotingHelper
.
exceptionSimpleDesc
(
e
));
log
.
warn
(
String
.
format
(
"consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s"
,
//
log
.
warn
(
String
.
format
(
"consumeMessageDirectly exception: %s Group: %s Msgs: %s MQ: %s"
,
RemotingHelper
.
exceptionSimpleDesc
(
e
),
//
RemotingHelper
.
exceptionSimpleDesc
(
e
),
ConsumeMessageOrderlyService
.
this
.
consumerGroup
,
//
ConsumeMessageOrderlyService
.
this
.
consumerGroup
,
msgs
,
//
msgs
,
mq
),
e
);
mq
),
e
);
}
}
...
@@ -187,10 +187,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -187,10 +187,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
}
}
@Override
@Override
public
void
submitConsumeRequest
(
//
public
void
submitConsumeRequest
(
final
List
<
MessageExt
>
msgs
,
//
final
List
<
MessageExt
>
msgs
,
final
ProcessQueue
processQueue
,
//
final
ProcessQueue
processQueue
,
final
MessageQueue
messageQueue
,
//
final
MessageQueue
messageQueue
,
final
boolean
dispathToConsume
)
{
final
boolean
dispathToConsume
)
{
if
(
dispathToConsume
)
{
if
(
dispathToConsume
)
{
ConsumeRequest
consumeRequest
=
new
ConsumeRequest
(
processQueue
,
messageQueue
);
ConsumeRequest
consumeRequest
=
new
ConsumeRequest
(
processQueue
,
messageQueue
);
...
@@ -226,10 +226,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -226,10 +226,10 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
return
false
;
return
false
;
}
}
private
void
submitConsumeRequestLater
(
//
private
void
submitConsumeRequestLater
(
final
ProcessQueue
processQueue
,
//
final
ProcessQueue
processQueue
,
final
MessageQueue
messageQueue
,
//
final
MessageQueue
messageQueue
,
final
long
suspendTimeMillis
//
final
long
suspendTimeMillis
)
{
)
{
long
timeMillis
=
suspendTimeMillis
;
long
timeMillis
=
suspendTimeMillis
;
if
(
timeMillis
==
-
1
)
{
if
(
timeMillis
==
-
1
)
{
...
@@ -251,11 +251,11 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -251,11 +251,11 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
},
timeMillis
,
TimeUnit
.
MILLISECONDS
);
},
timeMillis
,
TimeUnit
.
MILLISECONDS
);
}
}
public
boolean
processConsumeResult
(
//
public
boolean
processConsumeResult
(
final
List
<
MessageExt
>
msgs
,
//
final
List
<
MessageExt
>
msgs
,
final
ConsumeOrderlyStatus
status
,
//
final
ConsumeOrderlyStatus
status
,
final
ConsumeOrderlyContext
context
,
//
final
ConsumeOrderlyContext
context
,
final
ConsumeRequest
consumeRequest
//
final
ConsumeRequest
consumeRequest
)
{
)
{
boolean
continueConsume
=
true
;
boolean
continueConsume
=
true
;
long
commitOffset
=
-
1L
;
long
commitOffset
=
-
1L
;
...
@@ -273,9 +273,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -273,9 +273,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
this
.
getConsumerStatsManager
().
incConsumeFailedTPS
(
consumerGroup
,
consumeRequest
.
getMessageQueue
().
getTopic
(),
msgs
.
size
());
this
.
getConsumerStatsManager
().
incConsumeFailedTPS
(
consumerGroup
,
consumeRequest
.
getMessageQueue
().
getTopic
(),
msgs
.
size
());
if
(
checkReconsumeTimes
(
msgs
))
{
if
(
checkReconsumeTimes
(
msgs
))
{
consumeRequest
.
getProcessQueue
().
makeMessageToCosumeAgain
(
msgs
);
consumeRequest
.
getProcessQueue
().
makeMessageToCosumeAgain
(
msgs
);
this
.
submitConsumeRequestLater
(
//
this
.
submitConsumeRequestLater
(
consumeRequest
.
getProcessQueue
(),
//
consumeRequest
.
getProcessQueue
(),
consumeRequest
.
getMessageQueue
(),
//
consumeRequest
.
getMessageQueue
(),
context
.
getSuspendCurrentQueueTimeMillis
());
context
.
getSuspendCurrentQueueTimeMillis
());
continueConsume
=
false
;
continueConsume
=
false
;
}
else
{
}
else
{
...
@@ -295,9 +295,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -295,9 +295,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
break
;
break
;
case
ROLLBACK:
case
ROLLBACK:
consumeRequest
.
getProcessQueue
().
rollback
();
consumeRequest
.
getProcessQueue
().
rollback
();
this
.
submitConsumeRequestLater
(
//
this
.
submitConsumeRequestLater
(
consumeRequest
.
getProcessQueue
(),
//
consumeRequest
.
getProcessQueue
(),
consumeRequest
.
getMessageQueue
(),
//
consumeRequest
.
getMessageQueue
(),
context
.
getSuspendCurrentQueueTimeMillis
());
context
.
getSuspendCurrentQueueTimeMillis
());
continueConsume
=
false
;
continueConsume
=
false
;
break
;
break
;
...
@@ -305,9 +305,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -305,9 +305,9 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
this
.
getConsumerStatsManager
().
incConsumeFailedTPS
(
consumerGroup
,
consumeRequest
.
getMessageQueue
().
getTopic
(),
msgs
.
size
());
this
.
getConsumerStatsManager
().
incConsumeFailedTPS
(
consumerGroup
,
consumeRequest
.
getMessageQueue
().
getTopic
(),
msgs
.
size
());
if
(
checkReconsumeTimes
(
msgs
))
{
if
(
checkReconsumeTimes
(
msgs
))
{
consumeRequest
.
getProcessQueue
().
makeMessageToCosumeAgain
(
msgs
);
consumeRequest
.
getProcessQueue
().
makeMessageToCosumeAgain
(
msgs
);
this
.
submitConsumeRequestLater
(
//
this
.
submitConsumeRequestLater
(
consumeRequest
.
getProcessQueue
(),
//
consumeRequest
.
getProcessQueue
(),
consumeRequest
.
getMessageQueue
(),
//
consumeRequest
.
getMessageQueue
(),
context
.
getSuspendCurrentQueueTimeMillis
());
context
.
getSuspendCurrentQueueTimeMillis
());
continueConsume
=
false
;
continueConsume
=
false
;
}
}
...
@@ -468,22 +468,22 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
...
@@ -468,22 +468,22 @@ public class ConsumeMessageOrderlyService implements ConsumeMessageService {
status
=
messageListener
.
consumeMessage
(
Collections
.
unmodifiableList
(
msgs
),
context
);
status
=
messageListener
.
consumeMessage
(
Collections
.
unmodifiableList
(
msgs
),
context
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
log
.
warn
(
"consumeMessage exception: {} Group: {} Msgs: {} MQ: {}"
,
//
log
.
warn
(
"consumeMessage exception: {} Group: {} Msgs: {} MQ: {}"
,
RemotingHelper
.
exceptionSimpleDesc
(
e
),
//
RemotingHelper
.
exceptionSimpleDesc
(
e
),
ConsumeMessageOrderlyService
.
this
.
consumerGroup
,
//
ConsumeMessageOrderlyService
.
this
.
consumerGroup
,
msgs
,
//
msgs
,
messageQueue
);
messageQueue
);
hasException
=
true
;
hasException
=
true
;
}
finally
{
}
finally
{
this
.
processQueue
.
getLockConsume
().
unlock
();
this
.
processQueue
.
getLockConsume
().
unlock
();
}
}
if
(
null
==
status
//
if
(
null
==
status
||
ConsumeOrderlyStatus
.
ROLLBACK
==
status
//
||
ConsumeOrderlyStatus
.
ROLLBACK
==
status
||
ConsumeOrderlyStatus
.
SUSPEND_CURRENT_QUEUE_A_MOMENT
==
status
)
{
||
ConsumeOrderlyStatus
.
SUSPEND_CURRENT_QUEUE_A_MOMENT
==
status
)
{
log
.
warn
(
"consumeMessage Orderly return not OK, Group: {} Msgs: {} MQ: {}"
,
//
log
.
warn
(
"consumeMessage Orderly return not OK, Group: {} Msgs: {} MQ: {}"
,
ConsumeMessageOrderlyService
.
this
.
consumerGroup
,
//
ConsumeMessageOrderlyService
.
this
.
consumerGroup
,
msgs
,
//
msgs
,
messageQueue
);
messageQueue
);
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageService.java
浏览文件 @
7f96008c
...
@@ -36,9 +36,9 @@ public interface ConsumeMessageService {
...
@@ -36,9 +36,9 @@ public interface ConsumeMessageService {
ConsumeMessageDirectlyResult
consumeMessageDirectly
(
final
MessageExt
msg
,
final
String
brokerName
);
ConsumeMessageDirectlyResult
consumeMessageDirectly
(
final
MessageExt
msg
,
final
String
brokerName
);
void
submitConsumeRequest
(
//
void
submitConsumeRequest
(
final
List
<
MessageExt
>
msgs
,
//
final
List
<
MessageExt
>
msgs
,
final
ProcessQueue
processQueue
,
//
final
ProcessQueue
processQueue
,
final
MessageQueue
messageQueue
,
//
final
MessageQueue
messageQueue
,
final
boolean
dispathToConsume
);
final
boolean
dispathToConsume
);
}
}
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
浏览文件 @
7f96008c
...
@@ -97,8 +97,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -97,8 +97,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
private
void
makeSureStateOK
()
throws
MQClientException
{
private
void
makeSureStateOK
()
throws
MQClientException
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
throw
new
MQClientException
(
"The consumer service state not OK, "
//
throw
new
MQClientException
(
"The consumer service state not OK, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
null
);
}
}
...
@@ -185,7 +185,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -185,7 +185,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
SubscriptionData
subscriptionData
;
SubscriptionData
subscriptionData
;
try
{
try
{
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
//
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
mq
.
getTopic
(),
subExpression
);
mq
.
getTopic
(),
subExpression
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
MQClientException
(
"parse subscription error"
,
e
);
throw
new
MQClientException
(
"parse subscription error"
,
e
);
...
@@ -193,18 +193,18 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -193,18 +193,18 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
long
timeoutMillis
=
block
?
this
.
defaultMQPullConsumer
.
getConsumerTimeoutMillisWhenSuspend
()
:
timeout
;
long
timeoutMillis
=
block
?
this
.
defaultMQPullConsumer
.
getConsumerTimeoutMillisWhenSuspend
()
:
timeout
;
PullResult
pullResult
=
this
.
pullAPIWrapper
.
pullKernelImpl
(
//
PullResult
pullResult
=
this
.
pullAPIWrapper
.
pullKernelImpl
(
mq
,
// 1
mq
,
subscriptionData
.
getSubString
(),
// 2
subscriptionData
.
getSubString
(),
0L
,
// 3
0L
,
offset
,
// 4
offset
,
maxNums
,
// 5
maxNums
,
sysFlag
,
// 6
sysFlag
,
0
,
// 7
0
,
this
.
defaultMQPullConsumer
.
getBrokerSuspendMaxTimeMillis
(),
// 8
this
.
defaultMQPullConsumer
.
getBrokerSuspendMaxTimeMillis
(),
timeoutMillis
,
// 9
timeoutMillis
,
CommunicationMode
.
SYNC
,
// 10
CommunicationMode
.
SYNC
,
null
// 11
null
);
);
this
.
pullAPIWrapper
.
processPullResult
(
mq
,
pullResult
,
subscriptionData
);
this
.
pullAPIWrapper
.
processPullResult
(
mq
,
pullResult
,
subscriptionData
);
if
(!
this
.
consumeMessageHookList
.
isEmpty
())
{
if
(!
this
.
consumeMessageHookList
.
isEmpty
())
{
...
@@ -225,7 +225,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -225,7 +225,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
public
void
subscriptionAutomatically
(
final
String
topic
)
{
public
void
subscriptionAutomatically
(
final
String
topic
)
{
if
(!
this
.
rebalanceImpl
.
getSubscriptionInner
().
containsKey
(
topic
))
{
if
(!
this
.
rebalanceImpl
.
getSubscriptionInner
().
containsKey
(
topic
))
{
try
{
try
{
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
//
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
topic
,
SubscriptionData
.
SUB_ALL
);
topic
,
SubscriptionData
.
SUB_ALL
);
this
.
rebalanceImpl
.
subscriptionInner
.
putIfAbsent
(
topic
,
subscriptionData
);
this
.
rebalanceImpl
.
subscriptionInner
.
putIfAbsent
(
topic
,
subscriptionData
);
}
catch
(
Exception
ignore
)
{
}
catch
(
Exception
ignore
)
{
...
@@ -372,13 +372,13 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -372,13 +372,13 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
this
.
pullAsyncImpl
(
mq
,
subExpression
,
offset
,
maxNums
,
pullCallback
,
false
,
timeout
);
this
.
pullAsyncImpl
(
mq
,
subExpression
,
offset
,
maxNums
,
pullCallback
,
false
,
timeout
);
}
}
private
void
pullAsyncImpl
(
//
private
void
pullAsyncImpl
(
final
MessageQueue
mq
,
//
final
MessageQueue
mq
,
final
String
subExpression
,
//
final
String
subExpression
,
final
long
offset
,
//
final
long
offset
,
final
int
maxNums
,
//
final
int
maxNums
,
final
PullCallback
pullCallback
,
//
final
PullCallback
pullCallback
,
final
boolean
block
,
//
final
boolean
block
,
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
InterruptedException
{
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
makeSureStateOK
();
...
@@ -405,7 +405,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -405,7 +405,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
final
SubscriptionData
subscriptionData
;
final
SubscriptionData
subscriptionData
;
try
{
try
{
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
//
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
mq
.
getTopic
(),
subExpression
);
mq
.
getTopic
(),
subExpression
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
MQClientException
(
"parse subscription error"
,
e
);
throw
new
MQClientException
(
"parse subscription error"
,
e
);
...
@@ -413,17 +413,17 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -413,17 +413,17 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
long
timeoutMillis
=
block
?
this
.
defaultMQPullConsumer
.
getConsumerTimeoutMillisWhenSuspend
()
:
timeout
;
long
timeoutMillis
=
block
?
this
.
defaultMQPullConsumer
.
getConsumerTimeoutMillisWhenSuspend
()
:
timeout
;
this
.
pullAPIWrapper
.
pullKernelImpl
(
//
this
.
pullAPIWrapper
.
pullKernelImpl
(
mq
,
// 1
mq
,
subscriptionData
.
getSubString
(),
// 2
subscriptionData
.
getSubString
(),
0L
,
// 3
0L
,
offset
,
// 4
offset
,
maxNums
,
// 5
maxNums
,
sysFlag
,
// 6
sysFlag
,
0
,
// 7
0
,
this
.
defaultMQPullConsumer
.
getBrokerSuspendMaxTimeMillis
(),
// 8
this
.
defaultMQPullConsumer
.
getBrokerSuspendMaxTimeMillis
(),
timeoutMillis
,
// 9
timeoutMillis
,
CommunicationMode
.
ASYNC
,
// 10
CommunicationMode
.
ASYNC
,
new
PullCallback
()
{
new
PullCallback
()
{
@Override
@Override
...
@@ -551,8 +551,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -551,8 +551,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
this
.
rebalanceImpl
.
setAllocateMessageQueueStrategy
(
this
.
defaultMQPullConsumer
.
getAllocateMessageQueueStrategy
());
this
.
rebalanceImpl
.
setAllocateMessageQueueStrategy
(
this
.
defaultMQPullConsumer
.
getAllocateMessageQueueStrategy
());
this
.
rebalanceImpl
.
setmQClientFactory
(
this
.
mQClientFactory
);
this
.
rebalanceImpl
.
setmQClientFactory
(
this
.
mQClientFactory
);
this
.
pullAPIWrapper
=
new
PullAPIWrapper
(
//
this
.
pullAPIWrapper
=
new
PullAPIWrapper
(
mQClientFactory
,
//
mQClientFactory
,
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
isUnitMode
());
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
isUnitMode
());
this
.
pullAPIWrapper
.
registerFilterMessageHook
(
filterMessageHookList
);
this
.
pullAPIWrapper
.
registerFilterMessageHook
(
filterMessageHookList
);
...
@@ -589,8 +589,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -589,8 +589,8 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
case
RUNNING:
case
RUNNING:
case
START_FAILED:
case
START_FAILED:
case
SHUTDOWN_ALREADY:
case
SHUTDOWN_ALREADY:
throw
new
MQClientException
(
"The PullConsumer service state not OK, maybe started once, "
//
throw
new
MQClientException
(
"The PullConsumer service state not OK, maybe started once, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
null
);
default
:
default
:
...
@@ -606,42 +606,42 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -606,42 +606,42 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
// consumerGroup
// consumerGroup
if
(
null
==
this
.
defaultMQPullConsumer
.
getConsumerGroup
())
{
if
(
null
==
this
.
defaultMQPullConsumer
.
getConsumerGroup
())
{
throw
new
MQClientException
(
throw
new
MQClientException
(
"consumerGroup is null"
//
"consumerGroup is null"
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
//
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
null
);
null
);
}
}
// consumerGroup
// consumerGroup
if
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
().
equals
(
MixAll
.
DEFAULT_CONSUMER_GROUP
))
{
if
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
().
equals
(
MixAll
.
DEFAULT_CONSUMER_GROUP
))
{
throw
new
MQClientException
(
throw
new
MQClientException
(
"consumerGroup can not equal "
//
"consumerGroup can not equal "
+
MixAll
.
DEFAULT_CONSUMER_GROUP
//
+
MixAll
.
DEFAULT_CONSUMER_GROUP
+
", please specify another one."
//
+
", please specify another one."
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
//
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
null
);
null
);
}
}
// messageModel
// messageModel
if
(
null
==
this
.
defaultMQPullConsumer
.
getMessageModel
())
{
if
(
null
==
this
.
defaultMQPullConsumer
.
getMessageModel
())
{
throw
new
MQClientException
(
throw
new
MQClientException
(
"messageModel is null"
//
"messageModel is null"
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
//
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
null
);
null
);
}
}
// allocateMessageQueueStrategy
// allocateMessageQueueStrategy
if
(
null
==
this
.
defaultMQPullConsumer
.
getAllocateMessageQueueStrategy
())
{
if
(
null
==
this
.
defaultMQPullConsumer
.
getAllocateMessageQueueStrategy
())
{
throw
new
MQClientException
(
throw
new
MQClientException
(
"allocateMessageQueueStrategy is null"
//
"allocateMessageQueueStrategy is null"
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
//
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
null
);
null
);
}
}
// allocateMessageQueueStrategy
// allocateMessageQueueStrategy
if
(
this
.
defaultMQPullConsumer
.
getConsumerTimeoutMillisWhenSuspend
()
<
this
.
defaultMQPullConsumer
.
getBrokerSuspendMaxTimeMillis
())
{
if
(
this
.
defaultMQPullConsumer
.
getConsumerTimeoutMillisWhenSuspend
()
<
this
.
defaultMQPullConsumer
.
getBrokerSuspendMaxTimeMillis
())
{
throw
new
MQClientException
(
throw
new
MQClientException
(
"Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis"
//
"Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis"
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
//
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_PARAMETER_CHECK_URL
),
null
);
null
);
}
}
}
}
...
@@ -651,7 +651,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
...
@@ -651,7 +651,7 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
Set
<
String
>
registerTopics
=
this
.
defaultMQPullConsumer
.
getRegisterTopics
();
Set
<
String
>
registerTopics
=
this
.
defaultMQPullConsumer
.
getRegisterTopics
();
if
(
registerTopics
!=
null
)
{
if
(
registerTopics
!=
null
)
{
for
(
final
String
topic
:
registerTopics
)
{
for
(
final
String
topic
:
registerTopics
)
{
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
//
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPullConsumer
.
getConsumerGroup
(),
topic
,
SubscriptionData
.
SUB_ALL
);
topic
,
SubscriptionData
.
SUB_ALL
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
topic
,
subscriptionData
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
topic
,
subscriptionData
);
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
浏览文件 @
7f96008c
...
@@ -297,10 +297,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -297,10 +297,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
pullRequest
.
getMessageQueue
().
getTopic
(),
pullResult
.
getMsgFoundList
().
size
());
pullRequest
.
getMessageQueue
().
getTopic
(),
pullResult
.
getMsgFoundList
().
size
());
boolean
dispathToConsume
=
processQueue
.
putMessage
(
pullResult
.
getMsgFoundList
());
boolean
dispathToConsume
=
processQueue
.
putMessage
(
pullResult
.
getMsgFoundList
());
DefaultMQPushConsumerImpl
.
this
.
consumeMessageService
.
submitConsumeRequest
(
//
DefaultMQPushConsumerImpl
.
this
.
consumeMessageService
.
submitConsumeRequest
(
pullResult
.
getMsgFoundList
(),
//
pullResult
.
getMsgFoundList
(),
processQueue
,
//
processQueue
,
pullRequest
.
getMessageQueue
(),
//
pullRequest
.
getMessageQueue
(),
dispathToConsume
);
dispathToConsume
);
if
(
DefaultMQPushConsumerImpl
.
this
.
defaultMQPushConsumer
.
getPullInterval
()
>
0
)
{
if
(
DefaultMQPushConsumerImpl
.
this
.
defaultMQPushConsumer
.
getPullInterval
()
>
0
)
{
...
@@ -311,12 +311,12 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -311,12 +311,12 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
}
}
}
if
(
pullResult
.
getNextBeginOffset
()
<
prevRequestOffset
//
if
(
pullResult
.
getNextBeginOffset
()
<
prevRequestOffset
||
firstMsgOffset
<
prevRequestOffset
)
{
||
firstMsgOffset
<
prevRequestOffset
)
{
log
.
warn
(
log
.
warn
(
"[BUG] pull message result maybe data wrong, nextBeginOffset: {} firstMsgOffset: {} prevRequestOffset: {}"
,
//
"[BUG] pull message result maybe data wrong, nextBeginOffset: {} firstMsgOffset: {} prevRequestOffset: {}"
,
pullResult
.
getNextBeginOffset
(),
//
pullResult
.
getNextBeginOffset
(),
firstMsgOffset
,
//
firstMsgOffset
,
prevRequestOffset
);
prevRequestOffset
);
}
}
...
@@ -336,7 +336,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -336,7 +336,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
DefaultMQPushConsumerImpl
.
this
.
executePullRequestImmediately
(
pullRequest
);
DefaultMQPushConsumerImpl
.
this
.
executePullRequestImmediately
(
pullRequest
);
break
;
break
;
case
OFFSET_ILLEGAL:
case
OFFSET_ILLEGAL:
log
.
warn
(
"the pull request offset illegal, {} {}"
,
//
log
.
warn
(
"the pull request offset illegal, {} {}"
,
pullRequest
.
toString
(),
pullResult
.
toString
());
pullRequest
.
toString
(),
pullResult
.
toString
());
pullRequest
.
setNextOffset
(
pullResult
.
getNextBeginOffset
());
pullRequest
.
setNextOffset
(
pullResult
.
getNextBeginOffset
());
...
@@ -396,26 +396,26 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -396,26 +396,26 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
classFilter
=
sd
.
isClassFilterMode
();
classFilter
=
sd
.
isClassFilterMode
();
}
}
int
sysFlag
=
PullSysFlag
.
buildSysFlag
(
//
int
sysFlag
=
PullSysFlag
.
buildSysFlag
(
commitOffsetEnable
,
// commitOffset
commitOffsetEnable
,
// commitOffset
true
,
// suspend
true
,
// suspend
subExpression
!=
null
,
// subscription
subExpression
!=
null
,
// subscription
classFilter
// class filter
classFilter
// class filter
);
);
try
{
try
{
this
.
pullAPIWrapper
.
pullKernelImpl
(
//
this
.
pullAPIWrapper
.
pullKernelImpl
(
pullRequest
.
getMessageQueue
(),
// 1
pullRequest
.
getMessageQueue
(),
subExpression
,
// 2
subExpression
,
subscriptionData
.
getExpressionType
(),
// 3
subscriptionData
.
getExpressionType
(),
subscriptionData
.
getSubVersion
(),
// 4
subscriptionData
.
getSubVersion
(),
pullRequest
.
getNextOffset
(),
// 5
pullRequest
.
getNextOffset
(),
this
.
defaultMQPushConsumer
.
getPullBatchSize
(),
// 6
this
.
defaultMQPushConsumer
.
getPullBatchSize
(),
sysFlag
,
// 7
sysFlag
,
commitOffsetValue
,
// 8
commitOffsetValue
,
BROKER_SUSPEND_MAX_TIME_MILLIS
,
// 9
BROKER_SUSPEND_MAX_TIME_MILLIS
,
CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND
,
// 10
CONSUMER_TIMEOUT_MILLIS_WHEN_SUSPEND
,
CommunicationMode
.
ASYNC
,
// 11
CommunicationMode
.
ASYNC
,
pullCallback
// 12
pullCallback
);
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"pullKernelImpl exception"
,
e
);
log
.
error
(
"pullKernelImpl exception"
,
e
);
...
@@ -425,8 +425,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -425,8 +425,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
private
void
makeSureStateOK
()
throws
MQClientException
{
private
void
makeSureStateOK
()
throws
MQClientException
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
throw
new
MQClientException
(
"The consumer service state not OK, "
//
throw
new
MQClientException
(
"The consumer service state not OK, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
null
);
}
}
...
@@ -608,8 +608,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -608,8 +608,8 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
case
RUNNING:
case
RUNNING:
case
START_FAILED:
case
START_FAILED:
case
SHUTDOWN_ALREADY:
case
SHUTDOWN_ALREADY:
throw
new
MQClientException
(
"The PushConsumer service state not OK, maybe started once, "
//
throw
new
MQClientException
(
"The PushConsumer service state not OK, maybe started once, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
null
);
default
:
default
:
...
@@ -764,7 +764,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -764,7 +764,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
for
(
final
Map
.
Entry
<
String
,
String
>
entry
:
sub
.
entrySet
())
{
for
(
final
Map
.
Entry
<
String
,
String
>
entry
:
sub
.
entrySet
())
{
final
String
topic
=
entry
.
getKey
();
final
String
topic
=
entry
.
getKey
();
final
String
subString
=
entry
.
getValue
();
final
String
subString
=
entry
.
getValue
();
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
//
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
topic
,
subString
);
topic
,
subString
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
topic
,
subscriptionData
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
topic
,
subscriptionData
);
}
}
...
@@ -779,7 +779,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -779,7 +779,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
break
;
break
;
case
CLUSTERING:
case
CLUSTERING:
final
String
retryTopic
=
MixAll
.
getRetryTopic
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
());
final
String
retryTopic
=
MixAll
.
getRetryTopic
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
());
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
//
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
retryTopic
,
SubscriptionData
.
SUB_ALL
);
retryTopic
,
SubscriptionData
.
SUB_ALL
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
retryTopic
,
subscriptionData
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
retryTopic
,
subscriptionData
);
break
;
break
;
...
@@ -811,7 +811,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -811,7 +811,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public
void
subscribe
(
String
topic
,
String
subExpression
)
throws
MQClientException
{
public
void
subscribe
(
String
topic
,
String
subExpression
)
throws
MQClientException
{
try
{
try
{
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
//
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
topic
,
subExpression
);
topic
,
subExpression
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
topic
,
subscriptionData
);
this
.
rebalanceImpl
.
getSubscriptionInner
().
put
(
topic
,
subscriptionData
);
if
(
this
.
mQClientFactory
!=
null
)
{
if
(
this
.
mQClientFactory
!=
null
)
{
...
@@ -824,7 +824,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
...
@@ -824,7 +824,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public
void
subscribe
(
String
topic
,
String
fullClassName
,
String
filterClassSource
)
throws
MQClientException
{
public
void
subscribe
(
String
topic
,
String
fullClassName
,
String
filterClassSource
)
throws
MQClientException
{
try
{
try
{
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
//
SubscriptionData
subscriptionData
=
FilterAPI
.
buildSubscriptionData
(
this
.
defaultMQPushConsumer
.
getConsumerGroup
(),
topic
,
"*"
);
topic
,
"*"
);
subscriptionData
.
setSubString
(
fullClassName
);
subscriptionData
.
setSubString
(
fullClassName
);
subscriptionData
.
setClassFilterMode
(
true
);
subscriptionData
.
setClassFilterMode
(
true
);
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
浏览文件 @
7f96008c
...
@@ -73,9 +73,9 @@ public abstract class RebalanceImpl {
...
@@ -73,9 +73,9 @@ public abstract class RebalanceImpl {
try
{
try
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
unlockBatchMQ
(
findBrokerResult
.
getBrokerAddr
(),
requestBody
,
1000
,
oneway
);
this
.
mQClientFactory
.
getMQClientAPIImpl
().
unlockBatchMQ
(
findBrokerResult
.
getBrokerAddr
(),
requestBody
,
1000
,
oneway
);
log
.
warn
(
"unlock messageQueue. group:{}, clientId:{}, mq:{}"
,
//
log
.
warn
(
"unlock messageQueue. group:{}, clientId:{}, mq:{}"
,
this
.
consumerGroup
,
//
this
.
consumerGroup
,
this
.
mQClientFactory
.
getClientId
(),
//
this
.
mQClientFactory
.
getClientId
(),
mq
);
mq
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"unlockBatchMQ exception, "
+
mq
,
e
);
log
.
error
(
"unlockBatchMQ exception, "
+
mq
,
e
);
...
@@ -245,10 +245,10 @@ public abstract class RebalanceImpl {
...
@@ -245,10 +245,10 @@ public abstract class RebalanceImpl {
boolean
changed
=
this
.
updateProcessQueueTableInRebalance
(
topic
,
mqSet
,
isOrder
);
boolean
changed
=
this
.
updateProcessQueueTableInRebalance
(
topic
,
mqSet
,
isOrder
);
if
(
changed
)
{
if
(
changed
)
{
this
.
messageQueueChanged
(
topic
,
mqSet
,
mqSet
);
this
.
messageQueueChanged
(
topic
,
mqSet
,
mqSet
);
log
.
info
(
"messageQueueChanged {} {} {} {}"
,
//
log
.
info
(
"messageQueueChanged {} {} {} {}"
,
consumerGroup
,
//
consumerGroup
,
topic
,
//
topic
,
mqSet
,
//
mqSet
,
mqSet
);
mqSet
);
}
}
}
else
{
}
else
{
...
@@ -280,10 +280,10 @@ public abstract class RebalanceImpl {
...
@@ -280,10 +280,10 @@ public abstract class RebalanceImpl {
List
<
MessageQueue
>
allocateResult
=
null
;
List
<
MessageQueue
>
allocateResult
=
null
;
try
{
try
{
allocateResult
=
strategy
.
allocate
(
//
allocateResult
=
strategy
.
allocate
(
this
.
consumerGroup
,
//
this
.
consumerGroup
,
this
.
mQClientFactory
.
getClientId
(),
//
this
.
mQClientFactory
.
getClientId
(),
mqAll
,
//
mqAll
,
cidAll
);
cidAll
);
}
catch
(
Throwable
e
)
{
}
catch
(
Throwable
e
)
{
log
.
error
(
"AllocateMessageQueueStrategy.allocate Exception. allocateMessageQueueStrategyName={}"
,
strategy
.
getName
(),
log
.
error
(
"AllocateMessageQueueStrategy.allocate Exception. allocateMessageQueueStrategyName={}"
,
strategy
.
getName
(),
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
浏览文件 @
7f96008c
...
@@ -74,8 +74,8 @@ public class RebalancePushImpl extends RebalanceImpl {
...
@@ -74,8 +74,8 @@ public class RebalancePushImpl extends RebalanceImpl {
pq
.
getLockConsume
().
unlock
();
pq
.
getLockConsume
().
unlock
();
}
}
}
else
{
}
else
{
log
.
warn
(
"[WRONG]mq is consuming, so can not unlock it, {}. maybe hanged for a while, {}"
,
//
log
.
warn
(
"[WRONG]mq is consuming, so can not unlock it, {}. maybe hanged for a while, {}"
,
mq
,
//
mq
,
pq
.
getTryUnlockTimes
());
pq
.
getTryUnlockTimes
());
pq
.
incTryUnlockTimes
();
pq
.
incTryUnlockTimes
();
...
...
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
浏览文件 @
7f96008c
...
@@ -148,10 +148,10 @@ public class MQClientInstance {
...
@@ -148,10 +148,10 @@ public class MQClientInstance {
this
.
consumerStatsManager
=
new
ConsumerStatsManager
(
this
.
scheduledExecutorService
);
this
.
consumerStatsManager
=
new
ConsumerStatsManager
(
this
.
scheduledExecutorService
);
log
.
info
(
"created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}"
,
//
log
.
info
(
"created a new client Instance, FactoryIndex: {} ClinetID: {} {} {}, serializeType={}"
,
this
.
instanceIndex
,
//
this
.
instanceIndex
,
this
.
clientId
,
//
this
.
clientId
,
this
.
clientConfig
,
//
this
.
clientConfig
,
MQVersion
.
getVersionDesc
(
MQVersion
.
CURRENT_VERSION
),
RemotingCommand
.
getSerializeTypeConfigInThisServer
());
MQVersion
.
getVersionDesc
(
MQVersion
.
CURRENT_VERSION
),
RemotingCommand
.
getSerializeTypeConfigInThisServer
());
}
}
...
@@ -727,13 +727,13 @@ public class MQClientInstance {
...
@@ -727,13 +727,13 @@ public class MQClientInstance {
classBody
=
filterClassSource
.
getBytes
(
MixAll
.
DEFAULT_CHARSET
);
classBody
=
filterClassSource
.
getBytes
(
MixAll
.
DEFAULT_CHARSET
);
classCRC
=
UtilAll
.
crc32
(
classBody
);
classCRC
=
UtilAll
.
crc32
(
classBody
);
}
catch
(
Exception
e1
)
{
}
catch
(
Exception
e1
)
{
log
.
warn
(
"uploadFilterClassToAllFilterServer Exception, ClassName: {} {}"
,
//
log
.
warn
(
"uploadFilterClassToAllFilterServer Exception, ClassName: {} {}"
,
fullClassName
,
//
fullClassName
,
RemotingHelper
.
exceptionSimpleDesc
(
e1
));
RemotingHelper
.
exceptionSimpleDesc
(
e1
));
}
}
TopicRouteData
topicRouteData
=
this
.
topicRouteTable
.
get
(
topic
);
TopicRouteData
topicRouteData
=
this
.
topicRouteTable
.
get
(
topic
);
if
(
topicRouteData
!=
null
//
if
(
topicRouteData
!=
null
&&
topicRouteData
.
getFilterServerTable
()
!=
null
&&
!
topicRouteData
.
getFilterServerTable
().
isEmpty
())
{
&&
topicRouteData
.
getFilterServerTable
()
!=
null
&&
!
topicRouteData
.
getFilterServerTable
().
isEmpty
())
{
Iterator
<
Entry
<
String
,
List
<
String
>>>
it
=
topicRouteData
.
getFilterServerTable
().
entrySet
().
iterator
();
Iterator
<
Entry
<
String
,
List
<
String
>>>
it
=
topicRouteData
.
getFilterServerTable
().
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
...
@@ -1006,10 +1006,10 @@ public class MQClientInstance {
...
@@ -1006,10 +1006,10 @@ public class MQClientInstance {
return
null
;
return
null
;
}
}
public
FindBrokerResult
findBrokerAddressInSubscribe
(
//
public
FindBrokerResult
findBrokerAddressInSubscribe
(
final
String
brokerName
,
//
final
String
brokerName
,
final
long
brokerId
,
//
final
long
brokerId
,
final
boolean
onlyThisBroker
//
final
boolean
onlyThisBroker
)
{
)
{
String
brokerAddr
=
null
;
String
brokerAddr
=
null
;
boolean
slave
=
false
;
boolean
slave
=
false
;
...
@@ -1102,7 +1102,6 @@ public class MQClientInstance {
...
@@ -1102,7 +1102,6 @@ public class MQClientInstance {
try
{
try
{
TimeUnit
.
SECONDS
.
sleep
(
10
);
TimeUnit
.
SECONDS
.
sleep
(
10
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
//
}
}
Iterator
<
MessageQueue
>
iterator
=
processQueueTable
.
keySet
().
iterator
();
Iterator
<
MessageQueue
>
iterator
=
processQueueTable
.
keySet
().
iterator
();
...
@@ -1171,8 +1170,8 @@ public class MQClientInstance {
...
@@ -1171,8 +1170,8 @@ public class MQClientInstance {
return
topicRouteTable
;
return
topicRouteTable
;
}
}
public
ConsumeMessageDirectlyResult
consumeMessageDirectly
(
final
MessageExt
msg
,
//
public
ConsumeMessageDirectlyResult
consumeMessageDirectly
(
final
MessageExt
msg
,
final
String
consumerGroup
,
//
final
String
consumerGroup
,
final
String
brokerName
)
{
final
String
brokerName
)
{
MQConsumerInner
mqConsumerInner
=
this
.
consumerTable
.
get
(
consumerGroup
);
MQConsumerInner
mqConsumerInner
=
this
.
consumerTable
.
get
(
consumerGroup
);
if
(
null
!=
mqConsumerInner
)
{
if
(
null
!=
mqConsumerInner
)
{
...
...
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
浏览文件 @
7f96008c
...
@@ -116,11 +116,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -116,11 +116,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
public
void
initTransactionEnv
()
{
public
void
initTransactionEnv
()
{
TransactionMQProducer
producer
=
(
TransactionMQProducer
)
this
.
defaultMQProducer
;
TransactionMQProducer
producer
=
(
TransactionMQProducer
)
this
.
defaultMQProducer
;
this
.
checkRequestQueue
=
new
LinkedBlockingQueue
<
Runnable
>(
producer
.
getCheckRequestHoldMax
());
this
.
checkRequestQueue
=
new
LinkedBlockingQueue
<
Runnable
>(
producer
.
getCheckRequestHoldMax
());
this
.
checkExecutor
=
new
ThreadPoolExecutor
(
//
this
.
checkExecutor
=
new
ThreadPoolExecutor
(
producer
.
getCheckThreadPoolMinSize
(),
//
producer
.
getCheckThreadPoolMinSize
(),
producer
.
getCheckThreadPoolMaxSize
(),
//
producer
.
getCheckThreadPoolMaxSize
(),
1000
*
60
,
//
1000
*
60
,
TimeUnit
.
MILLISECONDS
,
//
TimeUnit
.
MILLISECONDS
,
this
.
checkRequestQueue
);
this
.
checkRequestQueue
);
}
}
...
@@ -172,8 +172,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -172,8 +172,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
case
RUNNING:
case
RUNNING:
case
START_FAILED:
case
START_FAILED:
case
SHUTDOWN_ALREADY:
case
SHUTDOWN_ALREADY:
throw
new
MQClientException
(
"The producer service state not OK, maybe started once, "
//
throw
new
MQClientException
(
"The producer service state not OK, maybe started once, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
null
);
default
:
default
:
...
@@ -268,18 +268,18 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -268,18 +268,18 @@ public class DefaultMQProducerImpl implements MQProducerInner {
exception
=
e
;
exception
=
e
;
}
}
this
.
processTransactionState
(
//
this
.
processTransactionState
(
localTransactionState
,
//
localTransactionState
,
group
,
//
group
,
exception
);
exception
);
}
else
{
}
else
{
log
.
warn
(
"checkTransactionState, pick transactionCheckListener by group[{}] failed"
,
group
);
log
.
warn
(
"checkTransactionState, pick transactionCheckListener by group[{}] failed"
,
group
);
}
}
}
}
private
void
processTransactionState
(
//
private
void
processTransactionState
(
final
LocalTransactionState
localTransactionState
,
//
final
LocalTransactionState
localTransactionState
,
final
String
producerGroup
,
//
final
String
producerGroup
,
final
Throwable
exception
)
{
final
Throwable
exception
)
{
final
EndTransactionRequestHeader
thisHeader
=
new
EndTransactionRequestHeader
();
final
EndTransactionRequestHeader
thisHeader
=
new
EndTransactionRequestHeader
();
thisHeader
.
setCommitLogOffset
(
checkRequestHeader
.
getCommitLogOffset
());
thisHeader
.
setCommitLogOffset
(
checkRequestHeader
.
getCommitLogOffset
());
...
@@ -354,8 +354,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -354,8 +354,8 @@ public class DefaultMQProducerImpl implements MQProducerInner {
private
void
makeSureStateOK
()
throws
MQClientException
{
private
void
makeSureStateOK
()
throws
MQClientException
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
if
(
this
.
serviceState
!=
ServiceState
.
RUNNING
)
{
throw
new
MQClientException
(
"The producer service state not OK, "
//
throw
new
MQClientException
(
"The producer service state not OK, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
null
);
}
}
...
@@ -428,11 +428,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -428,11 +428,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
this
.
mqFaultStrategy
.
updateFaultItem
(
brokerName
,
currentLatency
,
isolation
);
this
.
mqFaultStrategy
.
updateFaultItem
(
brokerName
,
currentLatency
,
isolation
);
}
}
private
SendResult
sendDefaultImpl
(
//
private
SendResult
sendDefaultImpl
(
Message
msg
,
//
Message
msg
,
final
CommunicationMode
communicationMode
,
//
final
CommunicationMode
communicationMode
,
final
SendCallback
sendCallback
,
//
final
SendCallback
sendCallback
,
final
long
timeout
//
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
makeSureStateOK
();
Validators
.
checkMessage
(
msg
,
this
.
defaultMQProducer
);
Validators
.
checkMessage
(
msg
,
this
.
defaultMQProducer
);
...
@@ -579,11 +579,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -579,11 +579,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
}
}
}
private
SendResult
sendKernelImpl
(
final
Message
msg
,
//
private
SendResult
sendKernelImpl
(
final
Message
msg
,
final
MessageQueue
mq
,
//
final
MessageQueue
mq
,
final
CommunicationMode
communicationMode
,
//
final
CommunicationMode
communicationMode
,
final
SendCallback
sendCallback
,
//
final
SendCallback
sendCallback
,
final
TopicPublishInfo
topicPublishInfo
,
//
final
TopicPublishInfo
topicPublishInfo
,
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
.
getBrokerName
());
String
brokerAddr
=
this
.
mQClientFactory
.
findBrokerAddressInPublish
(
mq
.
getBrokerName
());
if
(
null
==
brokerAddr
)
{
if
(
null
==
brokerAddr
)
{
...
@@ -674,18 +674,18 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -674,18 +674,18 @@ public class DefaultMQProducerImpl implements MQProducerInner {
SendResult
sendResult
=
null
;
SendResult
sendResult
=
null
;
switch
(
communicationMode
)
{
switch
(
communicationMode
)
{
case
ASYNC:
case
ASYNC:
sendResult
=
this
.
mQClientFactory
.
getMQClientAPIImpl
().
sendMessage
(
//
sendResult
=
this
.
mQClientFactory
.
getMQClientAPIImpl
().
sendMessage
(
brokerAddr
,
// 1
brokerAddr
,
mq
.
getBrokerName
(),
// 2
mq
.
getBrokerName
(),
msg
,
// 3
msg
,
requestHeader
,
// 4
requestHeader
,
timeout
,
// 5
timeout
,
communicationMode
,
// 6
communicationMode
,
sendCallback
,
// 7
sendCallback
,
topicPublishInfo
,
// 8
topicPublishInfo
,
this
.
mQClientFactory
,
// 9
this
.
mQClientFactory
,
this
.
defaultMQProducer
.
getRetryTimesWhenSendAsyncFailed
(),
// 10
this
.
defaultMQProducer
.
getRetryTimesWhenSendAsyncFailed
(),
context
,
//
context
,
this
);
this
);
break
;
break
;
case
ONEWAY:
case
ONEWAY:
...
@@ -887,12 +887,12 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -887,12 +887,12 @@ public class DefaultMQProducerImpl implements MQProducerInner {
return
this
.
sendSelectImpl
(
msg
,
selector
,
arg
,
CommunicationMode
.
SYNC
,
null
,
timeout
);
return
this
.
sendSelectImpl
(
msg
,
selector
,
arg
,
CommunicationMode
.
SYNC
,
null
,
timeout
);
}
}
private
SendResult
sendSelectImpl
(
//
private
SendResult
sendSelectImpl
(
Message
msg
,
//
Message
msg
,
MessageQueueSelector
selector
,
//
MessageQueueSelector
selector
,
Object
arg
,
//
Object
arg
,
final
CommunicationMode
communicationMode
,
//
final
CommunicationMode
communicationMode
,
final
SendCallback
sendCallback
,
final
long
timeout
//
final
SendCallback
sendCallback
,
final
long
timeout
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
)
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
this
.
makeSureStateOK
();
this
.
makeSureStateOK
();
Validators
.
checkMessage
(
msg
,
this
.
defaultMQProducer
);
Validators
.
checkMessage
(
msg
,
this
.
defaultMQProducer
);
...
@@ -1017,9 +1017,9 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -1017,9 +1017,9 @@ public class DefaultMQProducerImpl implements MQProducerInner {
return
send
(
msg
,
this
.
defaultMQProducer
.
getSendMsgTimeout
());
return
send
(
msg
,
this
.
defaultMQProducer
.
getSendMsgTimeout
());
}
}
public
void
endTransaction
(
//
public
void
endTransaction
(
final
SendResult
sendResult
,
//
final
SendResult
sendResult
,
final
LocalTransactionState
localTransactionState
,
//
final
LocalTransactionState
localTransactionState
,
final
Throwable
localException
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
UnknownHostException
{
final
Throwable
localException
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
UnknownHostException
{
final
MessageId
id
;
final
MessageId
id
;
if
(
sendResult
.
getOffsetMsgId
()
!=
null
)
{
if
(
sendResult
.
getOffsetMsgId
()
!=
null
)
{
...
...
client/src/main/java/org/apache/rocketmq/client/impl/producer/MQProducerInner.java
浏览文件 @
7f96008c
...
@@ -28,9 +28,9 @@ public interface MQProducerInner {
...
@@ -28,9 +28,9 @@ public interface MQProducerInner {
TransactionCheckListener
checkListener
();
TransactionCheckListener
checkListener
();
void
checkTransactionState
(
//
void
checkTransactionState
(
final
String
addr
,
//
final
String
addr
,
final
MessageExt
msg
,
//
final
MessageExt
msg
,
final
CheckTransactionStateRequestHeader
checkRequestHeader
);
final
CheckTransactionStateRequestHeader
checkRequestHeader
);
void
updateTopicPublishInfo
(
final
String
topic
,
final
TopicPublishInfo
info
);
void
updateTopicPublishInfo
(
final
String
topic
,
final
TopicPublishInfo
info
);
...
...
common/src/main/java/org/apache/rocketmq/common/TopicConfig.java
浏览文件 @
7f96008c
...
@@ -46,24 +46,14 @@ public class TopicConfig {
...
@@ -46,24 +46,14 @@ public class TopicConfig {
public
String
encode
()
{
public
String
encode
()
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
// 1
sb
.
append
(
this
.
topicName
);
sb
.
append
(
this
.
topicName
);
sb
.
append
(
SEPARATOR
);
sb
.
append
(
SEPARATOR
);
// 2
sb
.
append
(
this
.
readQueueNums
);
sb
.
append
(
this
.
readQueueNums
);
sb
.
append
(
SEPARATOR
);
sb
.
append
(
SEPARATOR
);
// 3
sb
.
append
(
this
.
writeQueueNums
);
sb
.
append
(
this
.
writeQueueNums
);
sb
.
append
(
SEPARATOR
);
sb
.
append
(
SEPARATOR
);
// 4
sb
.
append
(
this
.
perm
);
sb
.
append
(
this
.
perm
);
sb
.
append
(
SEPARATOR
);
sb
.
append
(
SEPARATOR
);
// 5
sb
.
append
(
this
.
topicFilterType
);
sb
.
append
(
this
.
topicFilterType
);
return
sb
.
toString
();
return
sb
.
toString
();
...
...
common/src/main/java/org/apache/rocketmq/common/help/FAQUrl.java
浏览文件 @
7f96008c
...
@@ -18,44 +18,44 @@ package org.apache.rocketmq.common.help;
...
@@ -18,44 +18,44 @@ package org.apache.rocketmq.common.help;
public
class
FAQUrl
{
public
class
FAQUrl
{
public
static
final
String
APPLY_TOPIC_URL
=
//
public
static
final
String
APPLY_TOPIC_URL
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
NAME_SERVER_ADDR_NOT_EXIST_URL
=
//
public
static
final
String
NAME_SERVER_ADDR_NOT_EXIST_URL
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
GROUP_NAME_DUPLICATE_URL
=
//
public
static
final
String
GROUP_NAME_DUPLICATE_URL
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
CLIENT_PARAMETER_CHECK_URL
=
//
public
static
final
String
CLIENT_PARAMETER_CHECK_URL
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
SUBSCRIPTION_GROUP_NOT_EXIST
=
//
public
static
final
String
SUBSCRIPTION_GROUP_NOT_EXIST
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
CLIENT_SERVICE_NOT_OK
=
//
public
static
final
String
CLIENT_SERVICE_NOT_OK
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
// FAQ: No route info of this topic, TopicABC
// FAQ: No route info of this topic, TopicABC
public
static
final
String
NO_TOPIC_ROUTE_INFO
=
//
public
static
final
String
NO_TOPIC_ROUTE_INFO
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
LOAD_JSON_EXCEPTION
=
//
public
static
final
String
LOAD_JSON_EXCEPTION
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
SAME_GROUP_DIFFERENT_TOPIC
=
//
public
static
final
String
SAME_GROUP_DIFFERENT_TOPIC
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
MQLIST_NOT_EXIST
=
//
public
static
final
String
MQLIST_NOT_EXIST
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
UNEXPECTED_EXCEPTION_URL
=
//
public
static
final
String
UNEXPECTED_EXCEPTION_URL
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
SEND_MSG_FAILED
=
//
public
static
final
String
SEND_MSG_FAILED
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
public
static
final
String
UNKNOWN_HOST_EXCEPTION
=
//
public
static
final
String
UNKNOWN_HOST_EXCEPTION
=
"http://rocketmq.apache.org/docs/faq/"
;
"http://rocketmq.apache.org/docs/faq/"
;
private
static
final
String
TIP_STRING_BEGIN
=
"\nSee "
;
private
static
final
String
TIP_STRING_BEGIN
=
"\nSee "
;
...
...
common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
浏览文件 @
7f96008c
...
@@ -42,7 +42,7 @@ public class MessageClientIDSetter {
...
@@ -42,7 +42,7 @@ public class MessageClientIDSetter {
tempBuffer
.
put
(
createFakeIP
());
tempBuffer
.
put
(
createFakeIP
());
}
}
tempBuffer
.
position
(
6
);
tempBuffer
.
position
(
6
);
tempBuffer
.
putInt
(
MessageClientIDSetter
.
class
.
getClassLoader
().
hashCode
());
//4
tempBuffer
.
putInt
(
MessageClientIDSetter
.
class
.
getClassLoader
().
hashCode
());
FIX_STRING
=
UtilAll
.
bytes2string
(
tempBuffer
.
array
());
FIX_STRING
=
UtilAll
.
bytes2string
(
tempBuffer
.
array
());
setStartTime
(
System
.
currentTimeMillis
());
setStartTime
(
System
.
currentTimeMillis
());
COUNTER
=
new
AtomicInteger
(
0
);
COUNTER
=
new
AtomicInteger
(
0
);
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/body/ConsumerRunningInfo.java
浏览文件 @
7f96008c
...
@@ -130,15 +130,15 @@ public class ConsumerRunningInfo extends RemotingSerializable {
...
@@ -130,15 +130,15 @@ public class ConsumerRunningInfo extends RemotingSerializable {
if
(
orderMsg
)
{
if
(
orderMsg
)
{
if
(!
pq
.
isLocked
())
{
if
(!
pq
.
isLocked
())
{
sb
.
append
(
String
.
format
(
"%s %s can't lock for a while, %dms%n"
,
//
sb
.
append
(
String
.
format
(
"%s %s can't lock for a while, %dms%n"
,
clientId
,
//
clientId
,
mq
,
//
mq
,
System
.
currentTimeMillis
()
-
pq
.
getLastLockTimestamp
()));
System
.
currentTimeMillis
()
-
pq
.
getLastLockTimestamp
()));
}
else
{
}
else
{
if
(
pq
.
isDroped
()
&&
(
pq
.
getTryUnlockTimes
()
>
0
))
{
if
(
pq
.
isDroped
()
&&
(
pq
.
getTryUnlockTimes
()
>
0
))
{
sb
.
append
(
String
.
format
(
"%s %s unlock %d times, still failed%n"
,
//
sb
.
append
(
String
.
format
(
"%s %s unlock %d times, still failed%n"
,
clientId
,
//
clientId
,
mq
,
//
mq
,
pq
.
getTryUnlockTimes
()));
pq
.
getTryUnlockTimes
()));
}
}
}
}
...
@@ -147,9 +147,9 @@ public class ConsumerRunningInfo extends RemotingSerializable {
...
@@ -147,9 +147,9 @@ public class ConsumerRunningInfo extends RemotingSerializable {
long
diff
=
System
.
currentTimeMillis
()
-
pq
.
getLastConsumeTimestamp
();
long
diff
=
System
.
currentTimeMillis
()
-
pq
.
getLastConsumeTimestamp
();
if
(
diff
>
(
1000
*
60
)
&&
pq
.
getCachedMsgCount
()
>
0
)
{
if
(
diff
>
(
1000
*
60
)
&&
pq
.
getCachedMsgCount
()
>
0
)
{
sb
.
append
(
String
.
format
(
"%s %s can't consume for a while, maybe blocked, %dms%n"
,
//
sb
.
append
(
String
.
format
(
"%s %s can't consume for a while, maybe blocked, %dms%n"
,
clientId
,
//
clientId
,
mq
,
//
mq
,
diff
));
diff
));
}
}
}
}
...
@@ -211,10 +211,10 @@ public class ConsumerRunningInfo extends RemotingSerializable {
...
@@ -211,10 +211,10 @@ public class ConsumerRunningInfo extends RemotingSerializable {
int
i
=
0
;
int
i
=
0
;
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
SubscriptionData
next
=
it
.
next
();
SubscriptionData
next
=
it
.
next
();
String
item
=
String
.
format
(
"%03d Topic: %-40s ClassFilter: %-8s SubExpression: %s%n"
,
//
String
item
=
String
.
format
(
"%03d Topic: %-40s ClassFilter: %-8s SubExpression: %s%n"
,
++
i
,
//
++
i
,
next
.
getTopic
(),
//
next
.
getTopic
(),
next
.
isClassFilterMode
(),
//
next
.
isClassFilterMode
(),
next
.
getSubString
());
next
.
getSubString
());
sb
.
append
(
item
);
sb
.
append
(
item
);
...
@@ -223,20 +223,20 @@ public class ConsumerRunningInfo extends RemotingSerializable {
...
@@ -223,20 +223,20 @@ public class ConsumerRunningInfo extends RemotingSerializable {
{
{
sb
.
append
(
"\n\n#Consumer Offset#\n"
);
sb
.
append
(
"\n\n#Consumer Offset#\n"
);
sb
.
append
(
String
.
format
(
"%-32s %-32s %-4s %-20s%n"
,
//
sb
.
append
(
String
.
format
(
"%-32s %-32s %-4s %-20s%n"
,
"#Topic"
,
//
"#Topic"
,
"#Broker Name"
,
//
"#Broker Name"
,
"#QID"
,
//
"#QID"
,
"#Consumer Offset"
//
"#Consumer Offset"
));
));
Iterator
<
Entry
<
MessageQueue
,
ProcessQueueInfo
>>
it
=
this
.
mqTable
.
entrySet
().
iterator
();
Iterator
<
Entry
<
MessageQueue
,
ProcessQueueInfo
>>
it
=
this
.
mqTable
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
Entry
<
MessageQueue
,
ProcessQueueInfo
>
next
=
it
.
next
();
Entry
<
MessageQueue
,
ProcessQueueInfo
>
next
=
it
.
next
();
String
item
=
String
.
format
(
"%-32s %-32s %-4d %-20d%n"
,
//
String
item
=
String
.
format
(
"%-32s %-32s %-4d %-20d%n"
,
next
.
getKey
().
getTopic
(),
//
next
.
getKey
().
getTopic
(),
next
.
getKey
().
getBrokerName
(),
//
next
.
getKey
().
getBrokerName
(),
next
.
getKey
().
getQueueId
(),
//
next
.
getKey
().
getQueueId
(),
next
.
getValue
().
getCommitOffset
());
next
.
getValue
().
getCommitOffset
());
sb
.
append
(
item
);
sb
.
append
(
item
);
...
@@ -245,20 +245,20 @@ public class ConsumerRunningInfo extends RemotingSerializable {
...
@@ -245,20 +245,20 @@ public class ConsumerRunningInfo extends RemotingSerializable {
{
{
sb
.
append
(
"\n\n#Consumer MQ Detail#\n"
);
sb
.
append
(
"\n\n#Consumer MQ Detail#\n"
);
sb
.
append
(
String
.
format
(
"%-32s %-32s %-4s %-20s%n"
,
//
sb
.
append
(
String
.
format
(
"%-32s %-32s %-4s %-20s%n"
,
"#Topic"
,
//
"#Topic"
,
"#Broker Name"
,
//
"#Broker Name"
,
"#QID"
,
//
"#QID"
,
"#ProcessQueueInfo"
//
"#ProcessQueueInfo"
));
));
Iterator
<
Entry
<
MessageQueue
,
ProcessQueueInfo
>>
it
=
this
.
mqTable
.
entrySet
().
iterator
();
Iterator
<
Entry
<
MessageQueue
,
ProcessQueueInfo
>>
it
=
this
.
mqTable
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
Entry
<
MessageQueue
,
ProcessQueueInfo
>
next
=
it
.
next
();
Entry
<
MessageQueue
,
ProcessQueueInfo
>
next
=
it
.
next
();
String
item
=
String
.
format
(
"%-32s %-32s %-4d %s%n"
,
//
String
item
=
String
.
format
(
"%-32s %-32s %-4d %s%n"
,
next
.
getKey
().
getTopic
(),
//
next
.
getKey
().
getTopic
(),
next
.
getKey
().
getBrokerName
(),
//
next
.
getKey
().
getBrokerName
(),
next
.
getKey
().
getQueueId
(),
//
next
.
getKey
().
getQueueId
(),
next
.
getValue
().
toString
());
next
.
getValue
().
toString
());
sb
.
append
(
item
);
sb
.
append
(
item
);
...
@@ -267,27 +267,27 @@ public class ConsumerRunningInfo extends RemotingSerializable {
...
@@ -267,27 +267,27 @@ public class ConsumerRunningInfo extends RemotingSerializable {
{
{
sb
.
append
(
"\n\n#Consumer RT&TPS#\n"
);
sb
.
append
(
"\n\n#Consumer RT&TPS#\n"
);
sb
.
append
(
String
.
format
(
"%-32s %14s %14s %14s %14s %18s %25s%n"
,
//
sb
.
append
(
String
.
format
(
"%-32s %14s %14s %14s %14s %18s %25s%n"
,
"#Topic"
,
//
"#Topic"
,
"#Pull RT"
,
//
"#Pull RT"
,
"#Pull TPS"
,
//
"#Pull TPS"
,
"#Consume RT"
,
//
"#Consume RT"
,
"#ConsumeOK TPS"
,
//
"#ConsumeOK TPS"
,
"#ConsumeFailed TPS"
,
//
"#ConsumeFailed TPS"
,
"#ConsumeFailedMsgsInHour"
//
"#ConsumeFailedMsgsInHour"
));
));
Iterator
<
Entry
<
String
,
ConsumeStatus
>>
it
=
this
.
statusTable
.
entrySet
().
iterator
();
Iterator
<
Entry
<
String
,
ConsumeStatus
>>
it
=
this
.
statusTable
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
Entry
<
String
,
ConsumeStatus
>
next
=
it
.
next
();
Entry
<
String
,
ConsumeStatus
>
next
=
it
.
next
();
String
item
=
String
.
format
(
"%-32s %14.2f %14.2f %14.2f %14.2f %18.2f %25d%n"
,
//
String
item
=
String
.
format
(
"%-32s %14.2f %14.2f %14.2f %14.2f %18.2f %25d%n"
,
next
.
getKey
(),
//
next
.
getKey
(),
next
.
getValue
().
getPullRT
(),
//
next
.
getValue
().
getPullRT
(),
next
.
getValue
().
getPullTPS
(),
//
next
.
getValue
().
getPullTPS
(),
next
.
getValue
().
getConsumeRT
(),
//
next
.
getValue
().
getConsumeRT
(),
next
.
getValue
().
getConsumeOKTPS
(),
//
next
.
getValue
().
getConsumeOKTPS
(),
next
.
getValue
().
getConsumeFailedTPS
(),
//
next
.
getValue
().
getConsumeFailedTPS
(),
next
.
getValue
().
getConsumeFailedMsgs
()
//
next
.
getValue
().
getConsumeFailedMsgs
()
);
);
sb
.
append
(
item
);
sb
.
append
(
item
);
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumeStatsRequestHeader.java
浏览文件 @
7f96008c
...
@@ -27,8 +27,6 @@ public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
...
@@ -27,8 +27,6 @@ public class GetConsumeStatsRequestHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
public
String
getConsumerGroup
()
{
public
String
getConsumerGroup
()
{
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetConsumerStatusRequestHeader.java
浏览文件 @
7f96008c
...
@@ -32,7 +32,6 @@ public class GetConsumerStatusRequestHeader implements CommandCustomHeader {
...
@@ -32,7 +32,6 @@ public class GetConsumerStatusRequestHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
public
String
getTopic
()
{
public
String
getTopic
()
{
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetEarliestMsgStoretimeRequestHeader.java
浏览文件 @
7f96008c
...
@@ -32,7 +32,6 @@ public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader
...
@@ -32,7 +32,6 @@ public class GetEarliestMsgStoretimeRequestHeader implements CommandCustomHeader
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
public
String
getTopic
()
{
public
String
getTopic
()
{
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/QueryCorrectionOffsetHeader.java
浏览文件 @
7f96008c
...
@@ -33,7 +33,7 @@ public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
...
@@ -33,7 +33,7 @@ public class QueryCorrectionOffsetHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
public
String
getFilterGroups
()
{
public
String
getFilterGroups
()
{
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/SearchOffsetRequestHeader.java
浏览文件 @
7f96008c
...
@@ -34,7 +34,7 @@ public class SearchOffsetRequestHeader implements CommandCustomHeader {
...
@@ -34,7 +34,7 @@ public class SearchOffsetRequestHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientRequestHeader.java
浏览文件 @
7f96008c
...
@@ -57,7 +57,7 @@ public class UnregisterClientRequestHeader implements CommandCustomHeader {
...
@@ -57,7 +57,7 @@ public class UnregisterClientRequestHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
}
}
common/src/main/java/org/apache/rocketmq/common/protocol/header/UnregisterClientResponseHeader.java
浏览文件 @
7f96008c
...
@@ -24,7 +24,7 @@ public class UnregisterClientResponseHeader implements CommandCustomHeader {
...
@@ -24,7 +24,7 @@ public class UnregisterClientResponseHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/GetRouteInfoResponseHeader.java
已删除
100644 → 0
浏览文件 @
ffad6566
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* $Id: GetRouteInfoResponseHeader.java 1835 2013-05-16 02:00:50Z vintagewang@apache.org $
*/
package
org.apache.rocketmq.common.protocol.header.namesrv
;
import
org.apache.rocketmq.remoting.CommandCustomHeader
;
import
org.apache.rocketmq.remoting.exception.RemotingCommandException
;
public
class
GetRouteInfoResponseHeader
implements
CommandCustomHeader
{
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
common/src/main/java/org/apache/rocketmq/common/protocol/header/namesrv/RegisterOrderTopicRequestHeader.java
浏览文件 @
7f96008c
...
@@ -32,7 +32,7 @@ public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
...
@@ -32,7 +32,7 @@ public class RegisterOrderTopicRequestHeader implements CommandCustomHeader {
@Override
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
public
void
checkFields
()
throws
RemotingCommandException
{
// TODO Auto-generated method stub
}
}
public
String
getTopic
()
{
public
String
getTopic
()
{
...
...
common/src/main/java/org/apache/rocketmq/common/sysflag/TopicSysFlag.java
浏览文件 @
7f96008c
...
@@ -16,11 +16,7 @@
...
@@ -16,11 +16,7 @@
*/
*/
package
org.apache.rocketmq.common.sysflag
;
package
org.apache.rocketmq.common.sysflag
;
/**
*
*
*/
public
class
TopicSysFlag
{
public
class
TopicSysFlag
{
private
final
static
int
FLAG_UNIT
=
0x1
<<
0
;
private
final
static
int
FLAG_UNIT
=
0x1
<<
0
;
...
...
common/src/main/java/org/apache/rocketmq/common/utils/IOTinyUtils.java
浏览文件 @
7f96008c
...
@@ -114,9 +114,7 @@ public class IOTinyUtils {
...
@@ -114,9 +114,7 @@ public class IOTinyUtils {
fileOrDir
.
delete
();
fileOrDir
.
delete
();
}
}
/**
*/
public
static
void
cleanDirectory
(
File
directory
)
throws
IOException
{
public
static
void
cleanDirectory
(
File
directory
)
throws
IOException
{
if
(!
directory
.
exists
())
{
if
(!
directory
.
exists
())
{
String
message
=
directory
+
" does not exist"
;
String
message
=
directory
+
" does not exist"
;
...
...
example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
浏览文件 @
7f96008c
...
@@ -35,9 +35,7 @@ public class PushConsumer {
...
@@ -35,9 +35,7 @@ public class PushConsumer {
consumer
.
setConsumeTimestamp
(
"20170422221800"
);
consumer
.
setConsumeTimestamp
(
"20170422221800"
);
consumer
.
registerMessageListener
(
new
MessageListenerConcurrently
()
{
consumer
.
registerMessageListener
(
new
MessageListenerConcurrently
()
{
/**
*/
@Override
@Override
public
ConsumeConcurrentlyStatus
consumeMessage
(
List
<
MessageExt
>
msgs
,
ConsumeConcurrentlyContext
context
)
{
public
ConsumeConcurrentlyStatus
consumeMessage
(
List
<
MessageExt
>
msgs
,
ConsumeConcurrentlyContext
context
)
{
System
.
out
.
printf
(
Thread
.
currentThread
().
getName
()
+
" Receive New Messages: "
+
msgs
+
"%n"
);
System
.
out
.
printf
(
Thread
.
currentThread
().
getName
()
+
" Receive New Messages: "
+
msgs
+
"%n"
);
...
...
example/src/main/resources/MessageFilterImpl.java
浏览文件 @
7f96008c
...
@@ -28,7 +28,7 @@ public class MessageFilterImpl implements MessageFilter {
...
@@ -28,7 +28,7 @@ public class MessageFilterImpl implements MessageFilter {
String
property
=
msg
.
getProperty
(
"SequenceId"
);
String
property
=
msg
.
getProperty
(
"SequenceId"
);
if
(
property
!=
null
)
{
if
(
property
!=
null
)
{
int
id
=
Integer
.
parseInt
(
property
);
int
id
=
Integer
.
parseInt
(
property
);
if
(((
id
%
10
)
==
0
)
&&
//
if
(((
id
%
10
)
==
0
)
&&
(
id
>
100
))
{
(
id
>
100
))
{
return
true
;
return
true
;
}
}
...
...
filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.java
浏览文件 @
7f96008c
...
@@ -56,7 +56,6 @@ public class SelectorParser implements SelectorParserConstants {
...
@@ -56,7 +56,6 @@ public class SelectorParser implements SelectorParserConstants {
// convertStringExpressions = true;
// convertStringExpressions = true;
// sql = sql.substring(CONVERT_STRING_EXPRESSIONS_PREFIX.length());
// sql = sql.substring(CONVERT_STRING_EXPRESSIONS_PREFIX.length());
// }
// }
//
// if( convertStringExpressions ) {
// if( convertStringExpressions ) {
// ComparisonExpression.CONVERT_STRING_EXPRESSIONS.set(true);
// ComparisonExpression.CONVERT_STRING_EXPRESSIONS.set(true);
// }
// }
...
...
filter/src/main/java/org/apache/rocketmq/filter/parser/SelectorParser.jj
浏览文件 @
7f96008c
...
@@ -82,7 +82,6 @@ public class SelectorParser {
...
@@ -82,7 +82,6 @@ public class SelectorParser {
//
convertStringExpressions
=
true
;
//
convertStringExpressions
=
true
;
//
sql
=
sql
.
substring
(
CONVERT_STRING_EXPRESSIONS_PREFIX
.
length
());
//
sql
=
sql
.
substring
(
CONVERT_STRING_EXPRESSIONS_PREFIX
.
length
());
//
}
//
}
//
//
if
(
convertStringExpressions
)
{
//
if
(
convertStringExpressions
)
{
//
ComparisonExpression
.
CONVERT_STRING_EXPRESSIONS
.
set
(
true
);
//
ComparisonExpression
.
CONVERT_STRING_EXPRESSIONS
.
set
(
true
);
//
}
//
}
...
...
namesrv/src/main/java/org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java
浏览文件 @
7f96008c
...
@@ -72,10 +72,10 @@ public class KVConfigManager {
...
@@ -72,10 +72,10 @@ public class KVConfigManager {
final
String
prev
=
kvTable
.
put
(
key
,
value
);
final
String
prev
=
kvTable
.
put
(
key
,
value
);
if
(
null
!=
prev
)
{
if
(
null
!=
prev
)
{
log
.
info
(
"putKVConfig update config item, Namespace: {} Key: {} Value: {}"
,
//
log
.
info
(
"putKVConfig update config item, Namespace: {} Key: {} Value: {}"
,
namespace
,
key
,
value
);
namespace
,
key
,
value
);
}
else
{
}
else
{
log
.
info
(
"putKVConfig create new config item, Namespace: {} Key: {} Value: {}"
,
//
log
.
info
(
"putKVConfig create new config item, Namespace: {} Key: {} Value: {}"
,
namespace
,
key
,
value
);
namespace
,
key
,
value
);
}
}
}
finally
{
}
finally
{
...
@@ -119,7 +119,7 @@ public class KVConfigManager {
...
@@ -119,7 +119,7 @@ public class KVConfigManager {
HashMap
<
String
,
String
>
kvTable
=
this
.
configTable
.
get
(
namespace
);
HashMap
<
String
,
String
>
kvTable
=
this
.
configTable
.
get
(
namespace
);
if
(
null
!=
kvTable
)
{
if
(
null
!=
kvTable
)
{
String
value
=
kvTable
.
remove
(
key
);
String
value
=
kvTable
.
remove
(
key
);
log
.
info
(
"deleteKVConfig delete a config item, Namespace: {} Key: {} Value: {}"
,
//
log
.
info
(
"deleteKVConfig delete a config item, Namespace: {} Key: {} Value: {}"
,
namespace
,
key
,
value
);
namespace
,
key
,
value
);
}
}
}
finally
{
}
finally
{
...
...
namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
浏览文件 @
7f96008c
...
@@ -131,9 +131,9 @@ public class RouteInfoManager {
...
@@ -131,9 +131,9 @@ public class RouteInfoManager {
String
oldAddr
=
brokerData
.
getBrokerAddrs
().
put
(
brokerId
,
brokerAddr
);
String
oldAddr
=
brokerData
.
getBrokerAddrs
().
put
(
brokerId
,
brokerAddr
);
registerFirst
=
registerFirst
||
(
null
==
oldAddr
);
registerFirst
=
registerFirst
||
(
null
==
oldAddr
);
if
(
null
!=
topicConfigWrapper
//
if
(
null
!=
topicConfigWrapper
&&
MixAll
.
MASTER_ID
==
brokerId
)
{
&&
MixAll
.
MASTER_ID
==
brokerId
)
{
if
(
this
.
isBrokerTopicConfigChanged
(
brokerAddr
,
topicConfigWrapper
.
getDataVersion
())
//
if
(
this
.
isBrokerTopicConfigChanged
(
brokerAddr
,
topicConfigWrapper
.
getDataVersion
())
||
registerFirst
)
{
||
registerFirst
)
{
ConcurrentMap
<
String
,
TopicConfig
>
tcTable
=
ConcurrentMap
<
String
,
TopicConfig
>
tcTable
=
topicConfigWrapper
.
getTopicConfigTable
();
topicConfigWrapper
.
getTopicConfigTable
();
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyDecoder.java
浏览文件 @
7f96008c
...
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
...
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
public
class
NettyDecoder
extends
LengthFieldBasedFrameDecoder
{
public
class
NettyDecoder
extends
LengthFieldBasedFrameDecoder
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
RemotingHelper
.
ROCKETMQ_REMOTING
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
RemotingHelper
.
ROCKETMQ_REMOTING
);
private
static
final
int
FRAME_MAX_LENGTH
=
//
private
static
final
int
FRAME_MAX_LENGTH
=
Integer
.
parseInt
(
System
.
getProperty
(
"com.rocketmq.remoting.frameMaxLength"
,
"16777216"
));
Integer
.
parseInt
(
System
.
getProperty
(
"com.rocketmq.remoting.frameMaxLength"
,
"16777216"
));
public
NettyDecoder
()
{
public
NettyDecoder
()
{
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
浏览文件 @
7f96008c
...
@@ -188,7 +188,7 @@ public abstract class NettyRemotingAbstract {
...
@@ -188,7 +188,7 @@ public abstract class NettyRemotingAbstract {
log
.
error
(
cmd
.
toString
());
log
.
error
(
cmd
.
toString
());
if
(!
cmd
.
isOnewayRPC
())
{
if
(!
cmd
.
isOnewayRPC
())
{
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
RemotingSysResponseCode
.
SYSTEM_ERROR
,
//
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
RemotingSysResponseCode
.
SYSTEM_ERROR
,
RemotingHelper
.
exceptionSimpleDesc
(
e
));
RemotingHelper
.
exceptionSimpleDesc
(
e
));
response
.
setOpaque
(
opaque
);
response
.
setOpaque
(
opaque
);
ctx
.
writeAndFlush
(
response
);
ctx
.
writeAndFlush
(
response
);
...
@@ -210,9 +210,9 @@ public abstract class NettyRemotingAbstract {
...
@@ -210,9 +210,9 @@ public abstract class NettyRemotingAbstract {
pair
.
getObject2
().
submit
(
requestTask
);
pair
.
getObject2
().
submit
(
requestTask
);
}
catch
(
RejectedExecutionException
e
)
{
}
catch
(
RejectedExecutionException
e
)
{
if
((
System
.
currentTimeMillis
()
%
10000
)
==
0
)
{
if
((
System
.
currentTimeMillis
()
%
10000
)
==
0
)
{
log
.
warn
(
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
())
//
log
.
warn
(
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
())
+
", too many requests and system thread pool busy, RejectedExecutionException "
//
+
", too many requests and system thread pool busy, RejectedExecutionException "
+
pair
.
getObject2
().
toString
()
//
+
pair
.
getObject2
().
toString
()
+
" request code: "
+
cmd
.
getCode
());
+
" request code: "
+
cmd
.
getCode
());
}
}
...
@@ -422,10 +422,10 @@ public abstract class NettyRemotingAbstract {
...
@@ -422,10 +422,10 @@ public abstract class NettyRemotingAbstract {
throw
new
RemotingTooMuchRequestException
(
"invokeAsyncImpl invoke too fast"
);
throw
new
RemotingTooMuchRequestException
(
"invokeAsyncImpl invoke too fast"
);
}
else
{
}
else
{
String
info
=
String
info
=
String
.
format
(
"invokeAsyncImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d"
,
//
String
.
format
(
"invokeAsyncImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d"
,
timeoutMillis
,
//
timeoutMillis
,
this
.
semaphoreAsync
.
getQueueLength
(),
//
this
.
semaphoreAsync
.
getQueueLength
(),
this
.
semaphoreAsync
.
availablePermits
()
//
this
.
semaphoreAsync
.
availablePermits
()
);
);
log
.
warn
(
info
);
log
.
warn
(
info
);
throw
new
RemotingTimeoutException
(
info
);
throw
new
RemotingTimeoutException
(
info
);
...
@@ -459,10 +459,10 @@ public abstract class NettyRemotingAbstract {
...
@@ -459,10 +459,10 @@ public abstract class NettyRemotingAbstract {
throw
new
RemotingTooMuchRequestException
(
"invokeOnewayImpl invoke too fast"
);
throw
new
RemotingTooMuchRequestException
(
"invokeOnewayImpl invoke too fast"
);
}
else
{
}
else
{
String
info
=
String
.
format
(
String
info
=
String
.
format
(
"invokeOnewayImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d"
,
//
"invokeOnewayImpl tryAcquire semaphore timeout, %dms, waiting thread nums: %d semaphoreAsyncValue: %d"
,
timeoutMillis
,
//
timeoutMillis
,
this
.
semaphoreOneway
.
getQueueLength
(),
//
this
.
semaphoreOneway
.
getQueueLength
(),
this
.
semaphoreOneway
.
availablePermits
()
//
this
.
semaphoreOneway
.
availablePermits
()
);
);
log
.
warn
(
info
);
log
.
warn
(
info
);
throw
new
RemotingTimeoutException
(
info
);
throw
new
RemotingTimeoutException
(
info
);
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
浏览文件 @
7f96008c
...
@@ -92,7 +92,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
...
@@ -92,7 +92,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
this
(
nettyClientConfig
,
null
);
this
(
nettyClientConfig
,
null
);
}
}
public
NettyRemotingClient
(
final
NettyClientConfig
nettyClientConfig
,
//
public
NettyRemotingClient
(
final
NettyClientConfig
nettyClientConfig
,
final
ChannelEventListener
channelEventListener
)
{
final
ChannelEventListener
channelEventListener
)
{
super
(
nettyClientConfig
.
getClientOnewaySemaphoreValue
(),
nettyClientConfig
.
getClientAsyncSemaphoreValue
());
super
(
nettyClientConfig
.
getClientOnewaySemaphoreValue
(),
nettyClientConfig
.
getClientAsyncSemaphoreValue
());
this
.
nettyClientConfig
=
nettyClientConfig
;
this
.
nettyClientConfig
=
nettyClientConfig
;
...
@@ -130,8 +130,8 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
...
@@ -130,8 +130,8 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
@Override
@Override
public
void
start
()
{
public
void
start
()
{
this
.
defaultEventExecutorGroup
=
new
DefaultEventExecutorGroup
(
//
this
.
defaultEventExecutorGroup
=
new
DefaultEventExecutorGroup
(
nettyClientConfig
.
getClientWorkerThreads
(),
//
nettyClientConfig
.
getClientWorkerThreads
(),
new
ThreadFactory
()
{
new
ThreadFactory
()
{
private
AtomicInteger
threadIndex
=
new
AtomicInteger
(
0
);
private
AtomicInteger
threadIndex
=
new
AtomicInteger
(
0
);
...
@@ -142,7 +142,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
...
@@ -142,7 +142,7 @@ public class NettyRemotingClient extends NettyRemotingAbstract implements Remoti
}
}
});
});
Bootstrap
handler
=
this
.
bootstrap
.
group
(
this
.
eventLoopGroupWorker
).
channel
(
NioSocketChannel
.
class
)
//
Bootstrap
handler
=
this
.
bootstrap
.
group
(
this
.
eventLoopGroupWorker
).
channel
(
NioSocketChannel
.
class
)
.
option
(
ChannelOption
.
TCP_NODELAY
,
true
)
.
option
(
ChannelOption
.
TCP_NODELAY
,
true
)
.
option
(
ChannelOption
.
SO_KEEPALIVE
,
false
)
.
option
(
ChannelOption
.
SO_KEEPALIVE
,
false
)
.
option
(
ChannelOption
.
CONNECT_TIMEOUT_MILLIS
,
nettyClientConfig
.
getConnectTimeoutMillis
())
.
option
(
ChannelOption
.
CONNECT_TIMEOUT_MILLIS
,
nettyClientConfig
.
getConnectTimeoutMillis
())
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyServerConfig.java
浏览文件 @
7f96008c
...
@@ -16,11 +16,7 @@
...
@@ -16,11 +16,7 @@
*/
*/
package
org.apache.rocketmq.remoting.netty
;
package
org.apache.rocketmq.remoting.netty
;
/**
*
*
*/
public
class
NettyServerConfig
implements
Cloneable
{
public
class
NettyServerConfig
implements
Cloneable
{
private
int
listenPort
=
8888
;
private
int
listenPort
=
8888
;
private
int
serverWorkerThreads
=
8
;
private
int
serverWorkerThreads
=
8
;
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettySystemConfig.java
浏览文件 @
7f96008c
...
@@ -20,23 +20,23 @@ package org.apache.rocketmq.remoting.netty;
...
@@ -20,23 +20,23 @@ package org.apache.rocketmq.remoting.netty;
public
class
NettySystemConfig
{
public
class
NettySystemConfig
{
public
static
final
String
COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE
=
public
static
final
String
COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE
=
"com.rocketmq.remoting.nettyPooledByteBufAllocatorEnable"
;
"com.rocketmq.remoting.nettyPooledByteBufAllocatorEnable"
;
public
static
final
String
COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE
=
//
public
static
final
String
COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE
=
"com.rocketmq.remoting.socket.sndbuf.size"
;
"com.rocketmq.remoting.socket.sndbuf.size"
;
public
static
final
String
COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE
=
//
public
static
final
String
COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE
=
"com.rocketmq.remoting.socket.rcvbuf.size"
;
"com.rocketmq.remoting.socket.rcvbuf.size"
;
public
static
final
String
COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE
=
//
public
static
final
String
COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE
=
"com.rocketmq.remoting.clientAsyncSemaphoreValue"
;
"com.rocketmq.remoting.clientAsyncSemaphoreValue"
;
public
static
final
String
COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE
=
//
public
static
final
String
COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE
=
"com.rocketmq.remoting.clientOnewaySemaphoreValue"
;
"com.rocketmq.remoting.clientOnewaySemaphoreValue"
;
public
static
final
boolean
NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE
=
//
public
static
final
boolean
NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE
=
Boolean
Boolean
.
parseBoolean
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE
,
"false"
));
.
parseBoolean
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_NETTY_POOLED_BYTE_BUF_ALLOCATOR_ENABLE
,
"false"
));
public
static
final
int
CLIENT_ASYNC_SEMAPHORE_VALUE
=
//
public
static
final
int
CLIENT_ASYNC_SEMAPHORE_VALUE
=
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE
,
"65535"
));
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_CLIENT_ASYNC_SEMAPHORE_VALUE
,
"65535"
));
public
static
final
int
CLIENT_ONEWAY_SEMAPHORE_VALUE
=
//
public
static
final
int
CLIENT_ONEWAY_SEMAPHORE_VALUE
=
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE
,
"65535"
));
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_CLIENT_ONEWAY_SEMAPHORE_VALUE
,
"65535"
));
public
static
int
socketSndbufSize
=
//
public
static
int
socketSndbufSize
=
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE
,
"65535"
));
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_SOCKET_SNDBUF_SIZE
,
"65535"
));
public
static
int
socketRcvbufSize
=
//
public
static
int
socketRcvbufSize
=
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE
,
"65535"
));
Integer
.
parseInt
(
System
.
getProperty
(
COM_ROCKETMQ_REMOTING_SOCKET_RCVBUF_SIZE
,
"65535"
));
}
}
store/src/main/java/org/apache/rocketmq/store/CommitLog.java
浏览文件 @
7f96008c
...
@@ -125,11 +125,11 @@ public class CommitLog {
...
@@ -125,11 +125,11 @@ public class CommitLog {
return
this
.
mappedFileQueue
.
remainHowManyDataToFlush
();
return
this
.
mappedFileQueue
.
remainHowManyDataToFlush
();
}
}
public
int
deleteExpiredFile
(
//
public
int
deleteExpiredFile
(
final
long
expiredTime
,
//
final
long
expiredTime
,
final
int
deleteFilesInterval
,
//
final
int
deleteFilesInterval
,
final
long
intervalForcibly
,
//
final
long
intervalForcibly
,
final
boolean
cleanImmediately
//
final
boolean
cleanImmediately
)
{
)
{
return
this
.
mappedFileQueue
.
deleteExpiredFileByTime
(
expiredTime
,
deleteFilesInterval
,
intervalForcibly
,
cleanImmediately
);
return
this
.
mappedFileQueue
.
deleteExpiredFileByTime
(
expiredTime
,
deleteFilesInterval
,
intervalForcibly
,
cleanImmediately
);
}
}
...
@@ -244,43 +244,30 @@ public class CommitLog {
...
@@ -244,43 +244,30 @@ public class CommitLog {
byte
[]
bytesContent
=
new
byte
[
totalSize
];
byte
[]
bytesContent
=
new
byte
[
totalSize
];
// 3 BODYCRC
int
bodyCRC
=
byteBuffer
.
getInt
();
int
bodyCRC
=
byteBuffer
.
getInt
();
// 4 QUEUEID
int
queueId
=
byteBuffer
.
getInt
();
int
queueId
=
byteBuffer
.
getInt
();
// 5 FLAG
int
flag
=
byteBuffer
.
getInt
();
int
flag
=
byteBuffer
.
getInt
();
// 6 QUEUEOFFSET
long
queueOffset
=
byteBuffer
.
getLong
();
long
queueOffset
=
byteBuffer
.
getLong
();
// 7 PHYSICALOFFSET
long
physicOffset
=
byteBuffer
.
getLong
();
long
physicOffset
=
byteBuffer
.
getLong
();
// 8 SYSFLAG
int
sysFlag
=
byteBuffer
.
getInt
();
int
sysFlag
=
byteBuffer
.
getInt
();
// 9 BORNTIMESTAMP
long
bornTimeStamp
=
byteBuffer
.
getLong
();
long
bornTimeStamp
=
byteBuffer
.
getLong
();
// 10
ByteBuffer
byteBuffer1
=
byteBuffer
.
get
(
bytesContent
,
0
,
8
);
ByteBuffer
byteBuffer1
=
byteBuffer
.
get
(
bytesContent
,
0
,
8
);
// 11 STORETIMESTAMP
long
storeTimestamp
=
byteBuffer
.
getLong
();
long
storeTimestamp
=
byteBuffer
.
getLong
();
// 12
ByteBuffer
byteBuffer2
=
byteBuffer
.
get
(
bytesContent
,
0
,
8
);
ByteBuffer
byteBuffer2
=
byteBuffer
.
get
(
bytesContent
,
0
,
8
);
// 13 RECONSUMETIMES
int
reconsumeTimes
=
byteBuffer
.
getInt
();
int
reconsumeTimes
=
byteBuffer
.
getInt
();
// 14 Prepared Transaction Offset
long
preparedTransactionOffset
=
byteBuffer
.
getLong
();
long
preparedTransactionOffset
=
byteBuffer
.
getLong
();
// 15 BODY
int
bodyLen
=
byteBuffer
.
getInt
();
int
bodyLen
=
byteBuffer
.
getInt
();
if
(
bodyLen
>
0
)
{
if
(
bodyLen
>
0
)
{
if
(
readBody
)
{
if
(
readBody
)
{
...
@@ -298,7 +285,6 @@ public class CommitLog {
...
@@ -298,7 +285,6 @@ public class CommitLog {
}
}
}
}
// 16 TOPIC
byte
topicLen
=
byteBuffer
.
get
();
byte
topicLen
=
byteBuffer
.
get
();
byteBuffer
.
get
(
bytesContent
,
0
,
topicLen
);
byteBuffer
.
get
(
bytesContent
,
0
,
topicLen
);
String
topic
=
new
String
(
bytesContent
,
0
,
topicLen
,
MessageDecoder
.
CHARSET_UTF8
);
String
topic
=
new
String
(
bytesContent
,
0
,
topicLen
,
MessageDecoder
.
CHARSET_UTF8
);
...
@@ -307,7 +293,6 @@ public class CommitLog {
...
@@ -307,7 +293,6 @@ public class CommitLog {
String
keys
=
""
;
String
keys
=
""
;
String
uniqKey
=
null
;
String
uniqKey
=
null
;
// 17 properties
short
propertiesLength
=
byteBuffer
.
getShort
();
short
propertiesLength
=
byteBuffer
.
getShort
();
Map
<
String
,
String
>
propertiesMap
=
null
;
Map
<
String
,
String
>
propertiesMap
=
null
;
if
(
propertiesLength
>
0
)
{
if
(
propertiesLength
>
0
)
{
...
@@ -355,19 +340,19 @@ public class CommitLog {
...
@@ -355,19 +340,19 @@ public class CommitLog {
return
new
DispatchRequest
(
totalSize
,
false
/* success */
);
return
new
DispatchRequest
(
totalSize
,
false
/* success */
);
}
}
return
new
DispatchRequest
(
//
return
new
DispatchRequest
(
topic
,
// 1
topic
,
queueId
,
// 2
queueId
,
physicOffset
,
// 3
physicOffset
,
totalSize
,
// 4
totalSize
,
tagsCode
,
// 5
tagsCode
,
storeTimestamp
,
// 6
storeTimestamp
,
queueOffset
,
// 7
queueOffset
,
keys
,
// 8
keys
,
uniqKey
,
//9
uniqKey
,
sysFlag
,
// 10
sysFlag
,
preparedTransactionOffset
,
// 11
preparedTransactionOffset
,
propertiesMap
// 12
propertiesMap
);
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
...
@@ -376,24 +361,23 @@ public class CommitLog {
...
@@ -376,24 +361,23 @@ public class CommitLog {
}
}
private
static
int
calMsgLength
(
int
bodyLength
,
int
topicLength
,
int
propertiesLength
)
{
private
static
int
calMsgLength
(
int
bodyLength
,
int
topicLength
,
int
propertiesLength
)
{
final
int
msgLen
=
4
// 1 TOTALSIZE
final
int
msgLen
=
4
//TOTALSIZE
+
4
// 2 MAGICCODE
+
4
//MAGICCODE
+
4
// 3 BODYCRC
+
4
//BODYCRC
+
4
// 4 QUEUEID
+
4
//QUEUEID
+
4
// 5 FLAG
+
4
//FLAG
+
8
// 6 QUEUEOFFSET
+
8
//QUEUEOFFSET
+
8
// 7 PHYSICALOFFSET
+
8
//PHYSICALOFFSET
+
4
// 8 SYSFLAG
+
4
//SYSFLAG
+
8
// 9 BORNTIMESTAMP
+
8
//BORNTIMESTAMP
+
8
// 10 BORNHOST
+
8
//BORNHOST
+
8
// 11 STORETIMESTAMP
+
8
//STORETIMESTAMP
+
8
// 12 STOREHOSTADDRESS
+
8
//STOREHOSTADDRESS
+
4
// 13 RECONSUMETIMES
+
4
//RECONSUMETIMES
+
8
// 14 Prepared Transaction Offset
+
8
//Prepared Transaction Offset
+
4
+
(
bodyLength
>
0
?
bodyLength
:
0
)
// 14 BODY
+
4
+
(
bodyLength
>
0
?
bodyLength
:
0
)
//BODY
+
1
+
topicLength
// 15 TOPIC
+
1
+
topicLength
//TOPIC
+
2
+
(
propertiesLength
>
0
?
propertiesLength
:
0
)
// 16
+
2
+
(
propertiesLength
>
0
?
propertiesLength
:
0
)
//propertiesLength
// propertiesLength
+
0
;
+
0
;
return
msgLen
;
return
msgLen
;
}
}
...
@@ -500,18 +484,18 @@ public class CommitLog {
...
@@ -500,18 +484,18 @@ public class CommitLog {
return
false
;
return
false
;
}
}
if
(
this
.
defaultMessageStore
.
getMessageStoreConfig
().
isMessageIndexEnable
()
//
if
(
this
.
defaultMessageStore
.
getMessageStoreConfig
().
isMessageIndexEnable
()
&&
this
.
defaultMessageStore
.
getMessageStoreConfig
().
isMessageIndexSafe
())
{
&&
this
.
defaultMessageStore
.
getMessageStoreConfig
().
isMessageIndexSafe
())
{
if
(
storeTimestamp
<=
this
.
defaultMessageStore
.
getStoreCheckpoint
().
getMinTimestampIndex
())
{
if
(
storeTimestamp
<=
this
.
defaultMessageStore
.
getStoreCheckpoint
().
getMinTimestampIndex
())
{
log
.
info
(
"find check timestamp, {} {}"
,
//
log
.
info
(
"find check timestamp, {} {}"
,
storeTimestamp
,
//
storeTimestamp
,
UtilAll
.
timeMillisToHumanString
(
storeTimestamp
));
UtilAll
.
timeMillisToHumanString
(
storeTimestamp
));
return
true
;
return
true
;
}
}
}
else
{
}
else
{
if
(
storeTimestamp
<=
this
.
defaultMessageStore
.
getStoreCheckpoint
().
getMinTimestamp
())
{
if
(
storeTimestamp
<=
this
.
defaultMessageStore
.
getStoreCheckpoint
().
getMinTimestamp
())
{
log
.
info
(
"find check timestamp, {} {}"
,
//
log
.
info
(
"find check timestamp, {} {}"
,
storeTimestamp
,
//
storeTimestamp
,
UtilAll
.
timeMillisToHumanString
(
storeTimestamp
));
UtilAll
.
timeMillisToHumanString
(
storeTimestamp
));
return
true
;
return
true
;
}
}
...
@@ -547,7 +531,7 @@ public class CommitLog {
...
@@ -547,7 +531,7 @@ public class CommitLog {
int
queueId
=
msg
.
getQueueId
();
int
queueId
=
msg
.
getQueueId
();
final
int
tranType
=
MessageSysFlag
.
getTransactionValue
(
msg
.
getSysFlag
());
final
int
tranType
=
MessageSysFlag
.
getTransactionValue
(
msg
.
getSysFlag
());
if
(
tranType
==
MessageSysFlag
.
TRANSACTION_NOT_TYPE
//
if
(
tranType
==
MessageSysFlag
.
TRANSACTION_NOT_TYPE
||
tranType
==
MessageSysFlag
.
TRANSACTION_COMMIT_TYPE
)
{
||
tranType
==
MessageSysFlag
.
TRANSACTION_COMMIT_TYPE
)
{
// Delay Delivery
// Delay Delivery
if
(
msg
.
getDelayTimeLevel
()
>
0
)
{
if
(
msg
.
getDelayTimeLevel
()
>
0
)
{
...
@@ -1270,8 +1254,6 @@ public class CommitLog {
...
@@ -1270,8 +1254,6 @@ public class CommitLog {
// 2 MAGICCODE
// 2 MAGICCODE
this
.
msgStoreItemMemory
.
putInt
(
CommitLog
.
BLANK_MAGIC_CODE
);
this
.
msgStoreItemMemory
.
putInt
(
CommitLog
.
BLANK_MAGIC_CODE
);
// 3 The remaining space may be any value
// 3 The remaining space may be any value
//
// Here the length of the specially set maxBlank
// Here the length of the specially set maxBlank
final
long
beginTimeMills
=
CommitLog
.
this
.
defaultMessageStore
.
now
();
final
long
beginTimeMills
=
CommitLog
.
this
.
defaultMessageStore
.
now
();
byteBuffer
.
put
(
this
.
msgStoreItemMemory
.
array
(),
0
,
maxBlank
);
byteBuffer
.
put
(
this
.
msgStoreItemMemory
.
array
(),
0
,
maxBlank
);
...
@@ -1391,7 +1373,6 @@ public class CommitLog {
...
@@ -1391,7 +1373,6 @@ public class CommitLog {
// 2 MAGICCODE
// 2 MAGICCODE
this
.
msgStoreItemMemory
.
putInt
(
CommitLog
.
BLANK_MAGIC_CODE
);
this
.
msgStoreItemMemory
.
putInt
(
CommitLog
.
BLANK_MAGIC_CODE
);
// 3 The remaining space may be any value
// 3 The remaining space may be any value
//
//ignore previous read
//ignore previous read
messagesByteBuff
.
reset
();
messagesByteBuff
.
reset
();
// Here the length of the specially set maxBlank
// Here the length of the specially set maxBlank
...
...
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
浏览文件 @
7f96008c
...
@@ -218,9 +218,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -218,9 +218,7 @@ public class DefaultMessageStore implements MessageStore {
this
.
shutdown
=
false
;
this
.
shutdown
=
false
;
}
}
/**
*/
public
void
shutdown
()
{
public
void
shutdown
()
{
if
(!
this
.
shutdown
)
{
if
(!
this
.
shutdown
)
{
this
.
shutdown
=
true
;
this
.
shutdown
=
true
;
...
@@ -392,7 +390,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -392,7 +390,7 @@ public class DefaultMessageStore implements MessageStore {
long
begin
=
this
.
getCommitLog
().
getBeginTimeInLock
();
long
begin
=
this
.
getCommitLog
().
getBeginTimeInLock
();
long
diff
=
this
.
systemClock
.
now
()
-
begin
;
long
diff
=
this
.
systemClock
.
now
()
-
begin
;
if
(
diff
<
10000000
//
if
(
diff
<
10000000
&&
diff
>
this
.
messageStoreConfig
.
getOsPageCacheBusyTimeOutMills
())
{
&&
diff
>
this
.
messageStoreConfig
.
getOsPageCacheBusyTimeOutMills
())
{
return
true
;
return
true
;
}
}
...
@@ -579,9 +577,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -579,9 +577,7 @@ public class DefaultMessageStore implements MessageStore {
return
getResult
;
return
getResult
;
}
}
/**
*/
public
long
getMaxOffsetInQueue
(
String
topic
,
int
queueId
)
{
public
long
getMaxOffsetInQueue
(
String
topic
,
int
queueId
)
{
ConsumeQueue
logic
=
this
.
findConsumeQueue
(
topic
,
queueId
);
ConsumeQueue
logic
=
this
.
findConsumeQueue
(
topic
,
queueId
);
if
(
logic
!=
null
)
{
if
(
logic
!=
null
)
{
...
@@ -592,9 +588,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -592,9 +588,7 @@ public class DefaultMessageStore implements MessageStore {
return
0
;
return
0
;
}
}
/**
*/
public
long
getMinOffsetInQueue
(
String
topic
,
int
queueId
)
{
public
long
getMinOffsetInQueue
(
String
topic
,
int
queueId
)
{
ConsumeQueue
logic
=
this
.
findConsumeQueue
(
topic
,
queueId
);
ConsumeQueue
logic
=
this
.
findConsumeQueue
(
topic
,
queueId
);
if
(
logic
!=
null
)
{
if
(
logic
!=
null
)
{
...
@@ -891,9 +885,9 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -891,9 +885,9 @@ public class DefaultMessageStore implements MessageStore {
ConcurrentMap
<
Integer
,
ConsumeQueue
>
queueTable
=
next
.
getValue
();
ConcurrentMap
<
Integer
,
ConsumeQueue
>
queueTable
=
next
.
getValue
();
for
(
ConsumeQueue
cq
:
queueTable
.
values
())
{
for
(
ConsumeQueue
cq
:
queueTable
.
values
())
{
cq
.
destroy
();
cq
.
destroy
();
log
.
info
(
"cleanUnusedTopic: {} {} ConsumeQueue cleaned"
,
//
log
.
info
(
"cleanUnusedTopic: {} {} ConsumeQueue cleaned"
,
cq
.
getTopic
(),
//
cq
.
getTopic
(),
cq
.
getQueueId
()
//
cq
.
getQueueId
()
);
);
this
.
commitLog
.
removeQueueFromTopicQueueTable
(
cq
.
getTopic
(),
cq
.
getQueueId
());
this
.
commitLog
.
removeQueueFromTopicQueueTable
(
cq
.
getTopic
(),
cq
.
getQueueId
());
...
@@ -922,17 +916,17 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -922,17 +916,17 @@ public class DefaultMessageStore implements MessageStore {
long
maxCLOffsetInConsumeQueue
=
nextQT
.
getValue
().
getLastOffset
();
long
maxCLOffsetInConsumeQueue
=
nextQT
.
getValue
().
getLastOffset
();
if
(
maxCLOffsetInConsumeQueue
==
-
1
)
{
if
(
maxCLOffsetInConsumeQueue
==
-
1
)
{
log
.
warn
(
"maybe ConsumeQueue was created just now. topic={} queueId={} maxPhysicOffset={} minLogicOffset={}."
,
//
log
.
warn
(
"maybe ConsumeQueue was created just now. topic={} queueId={} maxPhysicOffset={} minLogicOffset={}."
,
nextQT
.
getValue
().
getTopic
(),
//
nextQT
.
getValue
().
getTopic
(),
nextQT
.
getValue
().
getQueueId
(),
//
nextQT
.
getValue
().
getQueueId
(),
nextQT
.
getValue
().
getMaxPhysicOffset
(),
//
nextQT
.
getValue
().
getMaxPhysicOffset
(),
nextQT
.
getValue
().
getMinLogicOffset
());
nextQT
.
getValue
().
getMinLogicOffset
());
}
else
if
(
maxCLOffsetInConsumeQueue
<
minCommitLogOffset
)
{
}
else
if
(
maxCLOffsetInConsumeQueue
<
minCommitLogOffset
)
{
log
.
info
(
log
.
info
(
"cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}"
,
//
"cleanExpiredConsumerQueue: {} {} consumer queue destroyed, minCommitLogOffset: {} maxCLOffsetInConsumeQueue: {}"
,
topic
,
//
topic
,
nextQT
.
getKey
(),
//
nextQT
.
getKey
(),
minCommitLogOffset
,
//
minCommitLogOffset
,
maxCLOffsetInConsumeQueue
);
maxCLOffsetInConsumeQueue
);
DefaultMessageStore
.
this
.
commitLog
.
removeQueueFromTopicQueueTable
(
nextQT
.
getValue
().
getTopic
(),
DefaultMessageStore
.
this
.
commitLog
.
removeQueueFromTopicQueueTable
(
nextQT
.
getValue
().
getTopic
(),
...
@@ -1072,11 +1066,11 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -1072,11 +1066,11 @@ public class DefaultMessageStore implements MessageStore {
ConsumeQueue
logic
=
map
.
get
(
queueId
);
ConsumeQueue
logic
=
map
.
get
(
queueId
);
if
(
null
==
logic
)
{
if
(
null
==
logic
)
{
ConsumeQueue
newLogic
=
new
ConsumeQueue
(
//
ConsumeQueue
newLogic
=
new
ConsumeQueue
(
topic
,
//
topic
,
queueId
,
//
queueId
,
StorePathConfigHelper
.
getStorePathConsumeQueue
(
this
.
messageStoreConfig
.
getStorePathRootDir
()),
//
StorePathConfigHelper
.
getStorePathConsumeQueue
(
this
.
messageStoreConfig
.
getStorePathRootDir
()),
this
.
getMessageStoreConfig
().
getMapedFileSizeConsumeQueue
(),
//
this
.
getMessageStoreConfig
().
getMapedFileSizeConsumeQueue
(),
this
);
this
);
ConsumeQueue
oldLogic
=
map
.
putIfAbsent
(
queueId
,
newLogic
);
ConsumeQueue
oldLogic
=
map
.
putIfAbsent
(
queueId
,
newLogic
);
if
(
oldLogic
!=
null
)
{
if
(
oldLogic
!=
null
)
{
...
@@ -1462,11 +1456,11 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -1462,11 +1456,11 @@ public class DefaultMessageStore implements MessageStore {
boolean
cleanAtOnce
=
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
isCleanFileForciblyEnable
()
&&
this
.
cleanImmediately
;
boolean
cleanAtOnce
=
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
isCleanFileForciblyEnable
()
&&
this
.
cleanImmediately
;
log
.
info
(
"begin to delete before {} hours file. timeup: {} spacefull: {} manualDeleteFileSeveralTimes: {} cleanAtOnce: {}"
,
//
log
.
info
(
"begin to delete before {} hours file. timeup: {} spacefull: {} manualDeleteFileSeveralTimes: {} cleanAtOnce: {}"
,
fileReservedTime
,
//
fileReservedTime
,
timeup
,
//
timeup
,
spacefull
,
//
spacefull
,
manualDeleteFileSeveralTimes
,
//
manualDeleteFileSeveralTimes
,
cleanAtOnce
);
cleanAtOnce
);
fileReservedTime
*=
60
*
60
*
1000
;
fileReservedTime
*=
60
*
60
*
1000
;
...
@@ -1725,7 +1719,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -1725,7 +1719,7 @@ public class DefaultMessageStore implements MessageStore {
private
void
doReput
()
{
private
void
doReput
()
{
for
(
boolean
doNext
=
true
;
this
.
isCommitLogAvailable
()
&&
doNext
;
)
{
for
(
boolean
doNext
=
true
;
this
.
isCommitLogAvailable
()
&&
doNext
;
)
{
if
(
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
isDuplicationEnable
()
//
if
(
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
isDuplicationEnable
()
&&
this
.
reputFromOffset
>=
DefaultMessageStore
.
this
.
getConfirmOffset
())
{
&&
this
.
reputFromOffset
>=
DefaultMessageStore
.
this
.
getConfirmOffset
())
{
break
;
break
;
}
}
...
@@ -1751,7 +1745,7 @@ public class DefaultMessageStore implements MessageStore {
...
@@ -1751,7 +1745,7 @@ public class DefaultMessageStore implements MessageStore {
dispatchRequest
.
getTagsCode
(),
dispatchRequest
.
getStoreTimestamp
(),
dispatchRequest
.
getTagsCode
(),
dispatchRequest
.
getStoreTimestamp
(),
dispatchRequest
.
getBitMap
(),
dispatchRequest
.
getPropertiesMap
());
dispatchRequest
.
getBitMap
(),
dispatchRequest
.
getPropertiesMap
());
}
}
// FIXED BUG By shijia
this
.
reputFromOffset
+=
size
;
this
.
reputFromOffset
+=
size
;
readSize
+=
size
;
readSize
+=
size
;
if
(
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
getBrokerRole
()
==
BrokerRole
.
SLAVE
)
{
if
(
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
getBrokerRole
()
==
BrokerRole
.
SLAVE
)
{
...
...
store/src/main/java/org/apache/rocketmq/store/DispatchRequest.java
浏览文件 @
7f96008c
...
@@ -66,23 +66,14 @@ public class DispatchRequest {
...
@@ -66,23 +66,14 @@ public class DispatchRequest {
}
}
public
DispatchRequest
(
int
size
)
{
public
DispatchRequest
(
int
size
)
{
// 1
this
.
topic
=
""
;
this
.
topic
=
""
;
// 2
this
.
queueId
=
0
;
this
.
queueId
=
0
;
// 3
this
.
commitLogOffset
=
0
;
this
.
commitLogOffset
=
0
;
// 4
this
.
msgSize
=
size
;
this
.
msgSize
=
size
;
// 5
this
.
tagsCode
=
0
;
this
.
tagsCode
=
0
;
// 6
this
.
storeTimestamp
=
0
;
this
.
storeTimestamp
=
0
;
// 7
this
.
consumeQueueOffset
=
0
;
this
.
consumeQueueOffset
=
0
;
// 8
this
.
keys
=
""
;
this
.
keys
=
""
;
//9
this
.
uniqKey
=
null
;
this
.
uniqKey
=
null
;
this
.
sysFlag
=
0
;
this
.
sysFlag
=
0
;
this
.
preparedTransactionOffset
=
0
;
this
.
preparedTransactionOffset
=
0
;
...
@@ -91,23 +82,14 @@ public class DispatchRequest {
...
@@ -91,23 +82,14 @@ public class DispatchRequest {
}
}
public
DispatchRequest
(
int
size
,
boolean
success
)
{
public
DispatchRequest
(
int
size
,
boolean
success
)
{
// 1
this
.
topic
=
""
;
this
.
topic
=
""
;
// 2
this
.
queueId
=
0
;
this
.
queueId
=
0
;
// 3
this
.
commitLogOffset
=
0
;
this
.
commitLogOffset
=
0
;
// 4
this
.
msgSize
=
size
;
this
.
msgSize
=
size
;
// 5
this
.
tagsCode
=
0
;
this
.
tagsCode
=
0
;
// 6
this
.
storeTimestamp
=
0
;
this
.
storeTimestamp
=
0
;
// 7
this
.
consumeQueueOffset
=
0
;
this
.
consumeQueueOffset
=
0
;
// 8
this
.
keys
=
""
;
this
.
keys
=
""
;
// 9
this
.
uniqKey
=
null
;
this
.
uniqKey
=
null
;
this
.
sysFlag
=
0
;
this
.
sysFlag
=
0
;
this
.
preparedTransactionOffset
=
0
;
this
.
preparedTransactionOffset
=
0
;
...
...
store/src/main/java/org/apache/rocketmq/store/MappedFile.java
浏览文件 @
7f96008c
...
@@ -404,9 +404,7 @@ public class MappedFile extends ReferenceResource {
...
@@ -404,9 +404,7 @@ public class MappedFile extends ReferenceResource {
return
null
;
return
null
;
}
}
/**
*/
public
SelectMappedBufferResult
selectMappedBuffer
(
int
pos
)
{
public
SelectMappedBufferResult
selectMappedBuffer
(
int
pos
)
{
int
readPosition
=
getReadPosition
();
int
readPosition
=
getReadPosition
();
if
(
pos
<
readPosition
&&
pos
>=
0
)
{
if
(
pos
<
readPosition
&&
pos
>=
0
)
{
...
...
store/src/main/java/org/apache/rocketmq/store/MappedFileQueue.java
浏览文件 @
7f96008c
...
@@ -405,7 +405,6 @@ public class MappedFileQueue {
...
@@ -405,7 +405,6 @@ public class MappedFileQueue {
break
;
break
;
}
}
// TODO: Externalize this hardcoded value
if
(
destroy
&&
mappedFile
.
destroy
(
1000
*
60
))
{
if
(
destroy
&&
mappedFile
.
destroy
(
1000
*
60
))
{
files
.
add
(
mappedFile
);
files
.
add
(
mappedFile
);
deleteCount
++;
deleteCount
++;
...
...
store/src/main/java/org/apache/rocketmq/store/ha/HAConnection.java
浏览文件 @
7f96008c
...
@@ -78,10 +78,7 @@ public class HAConnection {
...
@@ -78,10 +78,7 @@ public class HAConnection {
return
socketChannel
;
return
socketChannel
;
}
}
/**
*
*/
class
ReadSocketService
extends
ServiceThread
{
class
ReadSocketService
extends
ServiceThread
{
private
static
final
int
READ_MAX_BUFFER_SIZE
=
1024
*
1024
;
private
static
final
int
READ_MAX_BUFFER_SIZE
=
1024
*
1024
;
private
final
Selector
selector
;
private
final
Selector
selector
;
...
@@ -194,10 +191,7 @@ public class HAConnection {
...
@@ -194,10 +191,7 @@ public class HAConnection {
}
}
}
}
/**
*
*/
class
WriteSocketService
extends
ServiceThread
{
class
WriteSocketService
extends
ServiceThread
{
private
final
Selector
selector
;
private
final
Selector
selector
;
private
final
SocketChannel
socketChannel
;
private
final
SocketChannel
socketChannel
;
...
@@ -333,9 +327,7 @@ public class HAConnection {
...
@@ -333,9 +327,7 @@ public class HAConnection {
HAConnection
.
log
.
info
(
this
.
getServiceName
()
+
" service end"
);
HAConnection
.
log
.
info
(
this
.
getServiceName
()
+
" service end"
);
}
}
/**
*/
private
boolean
transferData
()
throws
Exception
{
private
boolean
transferData
()
throws
Exception
{
int
writeSizeZeroTimes
=
0
;
int
writeSizeZeroTimes
=
0
;
// Write Header
// Write Header
...
...
store/src/main/java/org/apache/rocketmq/store/ha/HAService.java
浏览文件 @
7f96008c
...
@@ -85,9 +85,7 @@ public class HAService {
...
@@ -85,9 +85,7 @@ public class HAService {
return
result
;
return
result
;
}
}
/**
*/
public
void
notifyTransferSome
(
final
long
offset
)
{
public
void
notifyTransferSome
(
final
long
offset
)
{
for
(
long
value
=
this
.
push2SlaveMaxOffset
.
get
();
offset
>
value
;
)
{
for
(
long
value
=
this
.
push2SlaveMaxOffset
.
get
();
offset
>
value
;
)
{
boolean
ok
=
this
.
push2SlaveMaxOffset
.
compareAndSet
(
value
,
offset
);
boolean
ok
=
this
.
push2SlaveMaxOffset
.
compareAndSet
(
value
,
offset
);
...
@@ -374,17 +372,6 @@ public class HAService {
...
@@ -374,17 +372,6 @@ public class HAService {
return
!
this
.
reportOffset
.
hasRemaining
();
return
!
this
.
reportOffset
.
hasRemaining
();
}
}
// private void reallocateByteBuffer() {
// ByteBuffer bb = ByteBuffer.allocate(READ_MAX_BUFFER_SIZE);
// int remain = this.byteBufferRead.limit() - this.dispatchPostion;
// bb.put(this.byteBufferRead.array(), this.dispatchPostion, remain);
// this.dispatchPostion = 0;
// this.byteBufferRead = bb;
// }
/**
*/
private
void
reallocateByteBuffer
()
{
private
void
reallocateByteBuffer
()
{
int
remain
=
READ_MAX_BUFFER_SIZE
-
this
.
dispatchPostion
;
int
remain
=
READ_MAX_BUFFER_SIZE
-
this
.
dispatchPostion
;
if
(
remain
>
0
)
{
if
(
remain
>
0
)
{
...
@@ -426,7 +413,6 @@ public class HAService {
...
@@ -426,7 +413,6 @@ public class HAService {
break
;
break
;
}
}
}
else
{
}
else
{
// TODO ERROR
log
.
info
(
"HAClient, processReadEvent read socket < 0"
);
log
.
info
(
"HAClient, processReadEvent read socket < 0"
);
return
false
;
return
false
;
}
}
...
@@ -598,8 +584,6 @@ public class HAService {
...
@@ -598,8 +584,6 @@ public class HAService {
log
.
info
(
this
.
getServiceName
()
+
" service end"
);
log
.
info
(
this
.
getServiceName
()
+
" service end"
);
}
}
//
// private void disableWriteFlag() {
// private void disableWriteFlag() {
// if (this.socketChannel != null) {
// if (this.socketChannel != null) {
// SelectionKey sk = this.socketChannel.keyFor(this.selector);
// SelectionKey sk = this.socketChannel.keyFor(this.selector);
...
@@ -610,8 +594,6 @@ public class HAService {
...
@@ -610,8 +594,6 @@ public class HAService {
// }
// }
// }
// }
// }
// }
//
//
// private void enableWriteFlag() {
// private void enableWriteFlag() {
// if (this.socketChannel != null) {
// if (this.socketChannel != null) {
// SelectionKey sk = this.socketChannel.keyFor(this.selector);
// SelectionKey sk = this.socketChannel.keyFor(this.selector);
...
...
store/src/main/java/org/apache/rocketmq/store/index/IndexFile.java
浏览文件 @
7f96008c
...
@@ -208,7 +208,6 @@ public class IndexFile {
...
@@ -208,7 +208,6 @@ public class IndexFile {
if
(
slotValue
<=
invalidIndex
||
slotValue
>
this
.
indexHeader
.
getIndexCount
()
if
(
slotValue
<=
invalidIndex
||
slotValue
>
this
.
indexHeader
.
getIndexCount
()
||
this
.
indexHeader
.
getIndexCount
()
<=
1
)
{
||
this
.
indexHeader
.
getIndexCount
()
<=
1
)
{
// TODO NOTFOUND
}
else
{
}
else
{
for
(
int
nextIndexToRead
=
slotValue
;;)
{
for
(
int
nextIndexToRead
=
slotValue
;;)
{
if
(
phyOffsets
.
size
()
>=
maxNum
)
{
if
(
phyOffsets
.
size
()
>=
maxNum
)
{
...
...
store/src/main/java/org/apache/rocketmq/store/index/IndexHeader.java
浏览文件 @
7f96008c
...
@@ -20,11 +20,7 @@ import java.nio.ByteBuffer;
...
@@ -20,11 +20,7 @@ import java.nio.ByteBuffer;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
*
*
*/
public
class
IndexHeader
{
public
class
IndexHeader
{
public
static
final
int
INDEX_HEADER_SIZE
=
40
;
public
static
final
int
INDEX_HEADER_SIZE
=
40
;
private
static
int
beginTimestampIndex
=
0
;
private
static
int
beginTimestampIndex
=
0
;
...
...
store/src/main/java/org/apache/rocketmq/store/schedule/ScheduleMessageService.java
浏览文件 @
7f96008c
...
@@ -336,10 +336,7 @@ public class ScheduleMessageService extends ConfigManager {
...
@@ -336,10 +336,7 @@ public class ScheduleMessageService extends ConfigManager {
}
}
}
// end of if (bufferCQ != null)
}
// end of if (bufferCQ != null)
else
{
else
{
/*
*/
long
cqMinOffset
=
cq
.
getMinOffsetInQueue
();
long
cqMinOffset
=
cq
.
getMinOffsetInQueue
();
if
(
offset
<
cqMinOffset
)
{
if
(
offset
<
cqMinOffset
)
{
failScheduleOffset
=
cqMinOffset
;
failScheduleOffset
=
cqMinOffset
;
...
...
store/src/main/java/org/apache/rocketmq/store/stats/BrokerStats.java
浏览文件 @
7f96008c
...
@@ -38,9 +38,7 @@ public class BrokerStats {
...
@@ -38,9 +38,7 @@ public class BrokerStats {
this
.
defaultMessageStore
=
defaultMessageStore
;
this
.
defaultMessageStore
=
defaultMessageStore
;
}
}
/**
*/
public
void
record
()
{
public
void
record
()
{
this
.
msgPutTotalYesterdayMorning
=
this
.
msgPutTotalTodayMorning
;
this
.
msgPutTotalYesterdayMorning
=
this
.
msgPutTotalTodayMorning
;
this
.
msgGetTotalYesterdayMorning
=
this
.
msgGetTotalTodayMorning
;
this
.
msgGetTotalYesterdayMorning
=
this
.
msgGetTotalTodayMorning
;
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
浏览文件 @
7f96008c
...
@@ -119,7 +119,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
...
@@ -119,7 +119,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
if
(!
registerOK
)
{
if
(!
registerOK
)
{
this
.
serviceState
=
ServiceState
.
CREATE_JUST
;
this
.
serviceState
=
ServiceState
.
CREATE_JUST
;
throw
new
MQClientException
(
"The adminExt group["
+
this
.
defaultMQAdminExt
.
getAdminExtGroup
()
throw
new
MQClientException
(
"The adminExt group["
+
this
.
defaultMQAdminExt
.
getAdminExtGroup
()
+
"] has created already, specifed another name please."
//
+
"] has created already, specifed another name please."
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
GROUP_NAME_DUPLICATE_URL
),
null
);
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
GROUP_NAME_DUPLICATE_URL
),
null
);
}
}
...
@@ -132,8 +132,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
...
@@ -132,8 +132,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
case
RUNNING:
case
RUNNING:
case
START_FAILED:
case
START_FAILED:
case
SHUTDOWN_ALREADY:
case
SHUTDOWN_ALREADY:
throw
new
MQClientException
(
"The AdminExt service state not OK, maybe started once, "
//
throw
new
MQClientException
(
"The AdminExt service state not OK, maybe started once, "
+
this
.
serviceState
//
+
this
.
serviceState
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
+
FAQUrl
.
suggestTodo
(
FAQUrl
.
CLIENT_SERVICE_NOT_OK
),
null
);
default
:
default
:
break
;
break
;
...
@@ -185,13 +185,11 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
...
@@ -185,13 +185,11 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
@Override
public
SubscriptionGroupConfig
examineSubscriptionGroupConfig
(
String
addr
,
String
group
)
{
public
SubscriptionGroupConfig
examineSubscriptionGroupConfig
(
String
addr
,
String
group
)
{
// TODO Auto-generated method stub
return
null
;
return
null
;
}
}
@Override
@Override
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
{
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
{
// TODO Auto-generated method stub
return
null
;
return
null
;
}
}
...
@@ -344,8 +342,6 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
...
@@ -344,8 +342,6 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
@Override
@Override
public
void
putKVConfig
(
String
namespace
,
String
key
,
String
value
)
{
public
void
putKVConfig
(
String
namespace
,
String
key
,
String
value
)
{
// TODO Auto-generated method stub
}
}
@Override
@Override
...
...
tools/src/main/java/org/apache/rocketmq/tools/command/message/PrintMessageSubCommand.java
浏览文件 @
7f96008c
...
@@ -51,7 +51,6 @@ public class PrintMessageSubCommand implements SubCommand {
...
@@ -51,7 +51,6 @@ public class PrintMessageSubCommand implements SubCommand {
System
.
out
.
printf
(
"MSGID: %s %s BODY: %s%n"
,
msg
.
getMsgId
(),
msg
.
toString
(),
System
.
out
.
printf
(
"MSGID: %s %s BODY: %s%n"
,
msg
.
getMsgId
(),
msg
.
toString
(),
printBody
?
new
String
(
msg
.
getBody
(),
charsetName
)
:
"NOT PRINT BODY"
);
printBody
?
new
String
(
msg
.
getBody
(),
charsetName
)
:
"NOT PRINT BODY"
);
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
//
}
}
}
}
}
}
...
@@ -108,10 +107,10 @@ public class PrintMessageSubCommand implements SubCommand {
...
@@ -108,10 +107,10 @@ public class PrintMessageSubCommand implements SubCommand {
try
{
try
{
String
topic
=
commandLine
.
getOptionValue
(
't'
).
trim
();
String
topic
=
commandLine
.
getOptionValue
(
't'
).
trim
();
String
charsetName
=
//
String
charsetName
=
!
commandLine
.
hasOption
(
'c'
)
?
"UTF-8"
:
commandLine
.
getOptionValue
(
'c'
).
trim
();
!
commandLine
.
hasOption
(
'c'
)
?
"UTF-8"
:
commandLine
.
getOptionValue
(
'c'
).
trim
();
String
subExpression
=
//
String
subExpression
=
!
commandLine
.
hasOption
(
's'
)
?
"*"
:
commandLine
.
getOptionValue
(
's'
).
trim
();
!
commandLine
.
hasOption
(
's'
)
?
"*"
:
commandLine
.
getOptionValue
(
's'
).
trim
();
boolean
printBody
=
!
commandLine
.
hasOption
(
'd'
)
||
Boolean
.
parseBoolean
(
commandLine
.
getOptionValue
(
'd'
).
trim
());
boolean
printBody
=
!
commandLine
.
hasOption
(
'd'
)
||
Boolean
.
parseBoolean
(
commandLine
.
getOptionValue
(
'd'
).
trim
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录