Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
0c47fcf7
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0c47fcf7
编写于
9月 26, 2019
作者:
Q
qqeasonchen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add recommend client configs in rpc mode
上级
77728501
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
10 deletion
+34
-10
client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
...rc/main/java/org/apache/rocketmq/client/ClientConfig.java
+14
-2
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java
...tmq/client/impl/consumer/DefaultLitePullConsumerImpl.java
+7
-2
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+11
-6
example/src/main/java/org/apache/rocketmq/example/rpc/ResponseConsumer.java
...ava/org/apache/rocketmq/example/rpc/ResponseConsumer.java
+2
-0
未找到文件。
client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
浏览文件 @
0c47fcf7
...
...
@@ -53,6 +53,7 @@ public class ClientConfig {
* Offset persistent interval for consumer
*/
private
int
persistConsumerOffsetInterval
=
1000
*
5
;
private
long
pullTimeDelayMillsWhenException
=
1000
;
private
boolean
unitMode
=
false
;
private
String
unitName
;
private
boolean
vipChannelEnabled
=
Boolean
.
parseBoolean
(
System
.
getProperty
(
SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY
,
"false"
));
...
...
@@ -148,6 +149,7 @@ public class ClientConfig {
this
.
pollNameServerInterval
=
cc
.
pollNameServerInterval
;
this
.
heartbeatBrokerInterval
=
cc
.
heartbeatBrokerInterval
;
this
.
persistConsumerOffsetInterval
=
cc
.
persistConsumerOffsetInterval
;
this
.
pullTimeDelayMillsWhenException
=
cc
.
pullTimeDelayMillsWhenException
;
this
.
unitMode
=
cc
.
unitMode
;
this
.
unitName
=
cc
.
unitName
;
this
.
vipChannelEnabled
=
cc
.
vipChannelEnabled
;
...
...
@@ -165,6 +167,7 @@ public class ClientConfig {
cc
.
pollNameServerInterval
=
pollNameServerInterval
;
cc
.
heartbeatBrokerInterval
=
heartbeatBrokerInterval
;
cc
.
persistConsumerOffsetInterval
=
persistConsumerOffsetInterval
;
cc
.
pullTimeDelayMillsWhenException
=
pullTimeDelayMillsWhenException
;
cc
.
unitMode
=
unitMode
;
cc
.
unitName
=
unitName
;
cc
.
vipChannelEnabled
=
vipChannelEnabled
;
...
...
@@ -222,6 +225,14 @@ public class ClientConfig {
this
.
persistConsumerOffsetInterval
=
persistConsumerOffsetInterval
;
}
public
long
getPullTimeDelayMillsWhenException
()
{
return
pullTimeDelayMillsWhenException
;
}
public
void
setPullTimeDelayMillsWhenException
(
long
pullTimeDelayMillsWhenException
)
{
this
.
pullTimeDelayMillsWhenException
=
pullTimeDelayMillsWhenException
;
}
public
String
getUnitName
()
{
return
unitName
;
}
...
...
@@ -287,12 +298,13 @@ public class ClientConfig {
this
.
accessChannel
=
accessChannel
;
}
@Override
public
String
toString
()
{
return
"ClientConfig [namesrvAddr="
+
namesrvAddr
+
", clientIP="
+
clientIP
+
", instanceName="
+
instanceName
+
", clientCallbackExecutorThreads="
+
clientCallbackExecutorThreads
+
", pollNameServerInterval="
+
pollNameServerInterval
+
", heartbeatBrokerInterval="
+
heartbeatBrokerInterval
+
", persistConsumerOffsetInterval="
+
persistConsumerOffsetInterval
+
", unitMode="
+
unitMode
+
", unitName="
+
unitName
+
", vipChannelEnabled="
+
", heartbeatBrokerInterval="
+
heartbeatBrokerInterval
+
", persistConsumerOffsetInterval="
+
persistConsumerOffsetInterval
+
", pullTimeDelayMillsWhenException="
+
pullTimeDelayMillsWhenException
+
", unitMode="
+
unitMode
+
", unitName="
+
unitName
+
", vipChannelEnabled="
+
vipChannelEnabled
+
", useTLS="
+
useTLS
+
", language="
+
language
.
name
()
+
", namespace="
+
namespace
+
"]"
;
}
}
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java
浏览文件 @
0c47fcf7
...
...
@@ -110,7 +110,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner {
/**
* Delay some time when exception occur
*/
private
static
final
long
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
=
1000
;
private
long
pullTimeDelayMillsWhenException
=
1000
;
/**
* Flow control interval
*/
...
...
@@ -160,6 +160,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner {
return
new
Thread
(
r
,
"MonitorMessageQueueChangeThread"
);
}
});
this
.
pullTimeDelayMillsWhenException
=
defaultLitePullConsumer
.
getPullTimeDelayMillsWhenException
();
}
private
void
checkServiceState
()
{
...
...
@@ -787,7 +788,7 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner {
}
updatePullOffset
(
messageQueue
,
pullResult
.
getNextBeginOffset
());
}
catch
(
Throwable
e
)
{
pullDelayTimeMills
=
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
;
pullDelayTimeMills
=
pullTimeDelayMillsWhenException
;
log
.
error
(
"An error occurred in pull message process."
,
e
);
}
...
...
@@ -1075,6 +1076,10 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner {
}
public
void
setPullTimeDelayMillsWhenException
(
long
pullTimeDelayMillsWhenException
)
{
this
.
pullTimeDelayMillsWhenException
=
pullTimeDelayMillsWhenException
;
}
@Override
public
SendResult
reply
(
final
Message
requestMsg
,
final
byte
[]
replyContent
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
浏览文件 @
0c47fcf7
...
...
@@ -85,7 +85,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
/**
* Delay some time when exception occur
*/
private
static
final
long
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
=
3000
;
private
long
pullTimeDelayMillsWhenException
=
3000
;
/**
* Flow control interval
*/
...
...
@@ -117,6 +117,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
public
DefaultMQPushConsumerImpl
(
DefaultMQPushConsumer
defaultMQPushConsumer
,
RPCHook
rpcHook
)
{
this
.
defaultMQPushConsumer
=
defaultMQPushConsumer
;
this
.
rpcHook
=
rpcHook
;
this
.
pullTimeDelayMillsWhenException
=
defaultMQPushConsumer
.
getPullTimeDelayMillsWhenException
();
}
public
void
registerFilterMessageHook
(
final
FilterMessageHook
hook
)
{
...
...
@@ -224,7 +225,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
this
.
makeSureStateOK
();
}
catch
(
MQClientException
e
)
{
log
.
warn
(
"pullMessage exception, consumer state not ok"
,
e
);
this
.
executePullRequestLater
(
pullRequest
,
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
);
this
.
executePullRequestLater
(
pullRequest
,
pullTimeDelayMillsWhenException
);
return
;
}
...
...
@@ -284,7 +285,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
pullRequest
.
setNextOffset
(
offset
);
}
}
else
{
this
.
executePullRequestLater
(
pullRequest
,
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
);
this
.
executePullRequestLater
(
pullRequest
,
pullTimeDelayMillsWhenException
);
log
.
info
(
"pull message later because not locked in broker, {}"
,
pullRequest
);
return
;
}
...
...
@@ -292,7 +293,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
final
SubscriptionData
subscriptionData
=
this
.
rebalanceImpl
.
getSubscriptionInner
().
get
(
pullRequest
.
getMessageQueue
().
getTopic
());
if
(
null
==
subscriptionData
)
{
this
.
executePullRequestLater
(
pullRequest
,
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
);
this
.
executePullRequestLater
(
pullRequest
,
pullTimeDelayMillsWhenException
);
log
.
warn
(
"find the consumer's subscription failed, {}"
,
pullRequest
);
return
;
}
...
...
@@ -399,7 +400,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
log
.
warn
(
"execute the pull request exception"
,
e
);
}
DefaultMQPushConsumerImpl
.
this
.
executePullRequestLater
(
pullRequest
,
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
);
DefaultMQPushConsumerImpl
.
this
.
executePullRequestLater
(
pullRequest
,
pullTimeDelayMillsWhenException
);
}
};
...
...
@@ -446,7 +447,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
);
}
catch
(
Exception
e
)
{
log
.
error
(
"pullKernelImpl exception"
,
e
);
this
.
executePullRequestLater
(
pullRequest
,
PULL_TIME_DELAY_MILLS_WHEN_EXCEPTION
);
this
.
executePullRequestLater
(
pullRequest
,
pullTimeDelayMillsWhenException
);
}
}
...
...
@@ -1171,6 +1172,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
}
public
void
setPullTimeDelayMillsWhenException
(
long
pullTimeDelayMillsWhenException
)
{
this
.
pullTimeDelayMillsWhenException
=
pullTimeDelayMillsWhenException
;
}
@Override
public
SendResult
reply
(
final
Message
requestMsg
,
final
byte
[]
replyContent
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
...
...
example/src/main/java/org/apache/rocketmq/example/rpc/ResponseConsumer.java
浏览文件 @
0c47fcf7
...
...
@@ -37,6 +37,8 @@ public class ResponseConsumer {
DefaultMQPushConsumer
consumer
=
new
DefaultMQPushConsumer
(
consumerGroup
);
consumer
.
setConsumeFromWhere
(
ConsumeFromWhere
.
CONSUME_FROM_LAST_OFFSET
);
//recommend client configs
consumer
.
setPullTimeDelayMillsWhenException
(
0L
);
consumer
.
registerMessageListener
(
new
MessageListenerConcurrently
()
{
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录