Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
Rocketmq
提交
2dc75d32
R
Rocketmq
项目概览
s920243400
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2dc75d32
编写于
5月 26, 2021
作者:
Z
zhangjidi2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
The messageTrace related configurations is set as a property
上级
f244ee35
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
53 deletion
+44
-53
client/src/main/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumer.java
...che/rocketmq/client/consumer/DefaultLitePullConsumer.java
+39
-51
client/src/test/java/org/apache/rocketmq/client/trace/DefaultMQLitePullConsumerWithTraceTest.java
.../client/trace/DefaultMQLitePullConsumerWithTraceTest.java
+5
-2
未找到文件。
client/src/main/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumer.java
浏览文件 @
2dc75d32
...
...
@@ -165,6 +165,16 @@ public class DefaultLitePullConsumer extends ClientConfig implements LitePullCon
*/
private
TraceDispatcher
traceDispatcher
=
null
;
/**
* The flag for message trace
*/
private
boolean
enableMsgTrace
=
false
;
/**
* The name value of message trace topic.If you don't config,you can use the default trace topic name.
*/
private
String
customizedTraceTopic
;
/**
* Default constructor.
*/
...
...
@@ -200,57 +210,6 @@ public class DefaultLitePullConsumer extends ClientConfig implements LitePullCon
this
(
null
,
consumerGroup
,
rpcHook
);
}
/**
* Constructor specifying consumer group and enabled msg trace flag.
*
* @param consumerGroup Consumer group.
* @param enableMsgTrace Switch flag instance for message trace.
*/
public
DefaultLitePullConsumer
(
final
String
consumerGroup
,
boolean
enableMsgTrace
)
{
this
(
null
,
consumerGroup
,
null
,
enableMsgTrace
,
null
);
}
/**
* Constructor specifying consumer group, enabled msg trace flag and customized trace topic name.
*
* @param consumerGroup Consumer group.
* @param enableMsgTrace Switch flag instance for message trace.
* @param customizedTraceTopic The name value of message trace topic.If you don't config,you can use the default
* trace topic name.
*/
public
DefaultLitePullConsumer
(
final
String
consumerGroup
,
boolean
enableMsgTrace
,
final
String
customizedTraceTopic
)
{
this
(
null
,
consumerGroup
,
null
,
enableMsgTrace
,
customizedTraceTopic
);
}
/**
* Constructor specifying namespace, consumer group, RPC hook, enabled msg trace flag and customized trace topic
* name.
*
* @param namespace Namespace for this MQ Producer instance.
* @param consumerGroup Consume queue.
* @param rpcHook RPC hook to execute before each remoting command.
* @param enableMsgTrace Switch flag instance for message trace.
* @param customizedTraceTopic The name value of message trace topic.If you don't config,you can use the default
* trace topic name.
*/
public
DefaultLitePullConsumer
(
final
String
namespace
,
final
String
consumerGroup
,
RPCHook
rpcHook
,
boolean
enableMsgTrace
,
final
String
customizedTraceTopic
)
{
this
.
namespace
=
namespace
;
this
.
consumerGroup
=
consumerGroup
;
defaultLitePullConsumerImpl
=
new
DefaultLitePullConsumerImpl
(
this
,
rpcHook
);
if
(
enableMsgTrace
)
{
try
{
this
.
traceDispatcher
=
new
AsyncTraceDispatcher
(
consumerGroup
,
TraceDispatcher
.
Type
.
CONSUME
,
customizedTraceTopic
,
rpcHook
);
this
.
defaultLitePullConsumerImpl
.
registerConsumeMessageHook
(
new
ConsumeMessageTraceHookImpl
(
traceDispatcher
));
}
catch
(
Throwable
e
)
{
log
.
error
(
"system mqtrace hook init failed ,maybe can't send msg trace data"
);
}
}
}
/**
* Constructor specifying namespace, consumer group and RPC hook.
*
...
...
@@ -265,6 +224,7 @@ public class DefaultLitePullConsumer extends ClientConfig implements LitePullCon
@Override
public
void
start
()
throws
MQClientException
{
setTraceDispatcher
();
setConsumerGroup
(
NamespaceUtil
.
wrapNamespace
(
this
.
getNamespace
(),
this
.
consumerGroup
));
this
.
defaultLitePullConsumerImpl
.
start
();
if
(
null
!=
traceDispatcher
)
{
...
...
@@ -567,4 +527,32 @@ public class DefaultLitePullConsumer extends ClientConfig implements LitePullCon
public
TraceDispatcher
getTraceDispatcher
()
{
return
traceDispatcher
;
}
public
void
setCustomizedTraceTopic
(
String
customizedTraceTopic
)
{
this
.
customizedTraceTopic
=
customizedTraceTopic
;
}
private
void
setTraceDispatcher
()
{
if
(
isEnableMsgTrace
())
{
try
{
this
.
traceDispatcher
=
new
AsyncTraceDispatcher
(
consumerGroup
,
TraceDispatcher
.
Type
.
CONSUME
,
customizedTraceTopic
,
null
);
this
.
defaultLitePullConsumerImpl
.
registerConsumeMessageHook
(
new
ConsumeMessageTraceHookImpl
(
traceDispatcher
));
}
catch
(
Throwable
e
)
{
log
.
error
(
"system mqtrace hook init failed ,maybe can't send msg trace data"
);
}
}
}
public
String
getCustomizedTraceTopic
()
{
return
customizedTraceTopic
;
}
public
boolean
isEnableMsgTrace
()
{
return
enableMsgTrace
;
}
public
void
setEnableMsgTrace
(
boolean
enableMsgTrace
)
{
this
.
enableMsgTrace
=
enableMsgTrace
;
}
}
client/src/test/java/org/apache/rocketmq/client/trace/DefaultMQLitePullConsumerWithTraceTest.java
浏览文件 @
2dc75d32
...
...
@@ -148,7 +148,8 @@ public class DefaultMQLitePullConsumerWithTraceTest {
private
DefaultLitePullConsumer
createLitePullConsumerWithDefaultTraceTopic
()
throws
Exception
{
DefaultLitePullConsumer
litePullConsumer
=
new
DefaultLitePullConsumer
(
consumerGroup
+
System
.
currentTimeMillis
(),
true
);
DefaultLitePullConsumer
litePullConsumer
=
new
DefaultLitePullConsumer
(
consumerGroup
+
System
.
currentTimeMillis
());
litePullConsumer
.
setEnableMsgTrace
(
true
);
litePullConsumer
.
setNamesrvAddr
(
"127.0.0.1:9876"
);
litePullConsumer
.
subscribe
(
topic
,
"*"
);
suppressUpdateTopicRouteInfoFromNameServer
(
litePullConsumer
);
...
...
@@ -158,7 +159,9 @@ public class DefaultMQLitePullConsumerWithTraceTest {
}
private
DefaultLitePullConsumer
createLitePullConsumerWithCustomizedTraceTopic
()
throws
Exception
{
DefaultLitePullConsumer
litePullConsumer
=
new
DefaultLitePullConsumer
(
consumerGroup
+
System
.
currentTimeMillis
(),
true
,
customerTraceTopic
);
DefaultLitePullConsumer
litePullConsumer
=
new
DefaultLitePullConsumer
(
consumerGroup
+
System
.
currentTimeMillis
());
litePullConsumer
.
setEnableMsgTrace
(
true
);
litePullConsumer
.
setCustomizedTraceTopic
(
customerTraceTopic
);
litePullConsumer
.
setNamesrvAddr
(
"127.0.0.1:9876"
);
litePullConsumer
.
subscribe
(
topic
,
"*"
);
suppressUpdateTopicRouteInfoFromNameServer
(
litePullConsumer
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录