Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
4fb72cd1
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
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看板
提交
4fb72cd1
编写于
4月 17, 2018
作者:
S
shutian.lzh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix tests
上级
30abd95e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
86 addition
and
80 deletion
+86
-80
client/src/test/java/org/apache/rocketmq/client/log/ClientLoggerTest.java
...java/org/apache/rocketmq/client/log/ClientLoggerTest.java
+4
-1
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimpleProducer.java
...apache/rocketmq/example/openmessaging/SimpleProducer.java
+1
-0
openmessaging/src/main/java/io/openmessaging/rocketmq/config/ClientConfig.java
...n/java/io/openmessaging/rocketmq/config/ClientConfig.java
+62
-62
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/LocalMessageCache.java
...io/openmessaging/rocketmq/consumer/LocalMessageCache.java
+2
-2
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PullConsumerImpl.java
.../io/openmessaging/rocketmq/consumer/PullConsumerImpl.java
+2
-2
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java
.../io/openmessaging/rocketmq/consumer/PushConsumerImpl.java
+2
-2
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/AbstractOMSProducer.java
.../openmessaging/rocketmq/producer/AbstractOMSProducer.java
+2
-2
openmessaging/src/main/java/io/openmessaging/rocketmq/utils/BeanUtils.java
.../main/java/io/openmessaging/rocketmq/utils/BeanUtils.java
+1
-1
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PullConsumerImplTest.java
...openmessaging/rocketmq/consumer/PullConsumerImplTest.java
+4
-3
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PushConsumerImplTest.java
...openmessaging/rocketmq/consumer/PushConsumerImplTest.java
+3
-2
openmessaging/src/test/java/io/openmessaging/rocketmq/producer/ProducerImplTest.java
.../io/openmessaging/rocketmq/producer/ProducerImplTest.java
+1
-1
openmessaging/src/test/java/io/openmessaging/rocketmq/utils/BeanUtilsTest.java
...t/java/io/openmessaging/rocketmq/utils/BeanUtilsTest.java
+2
-2
未找到文件。
client/src/test/java/org/apache/rocketmq/client/log/ClientLoggerTest.java
浏览文件 @
4fb72cd1
...
...
@@ -49,7 +49,10 @@ public class ClientLoggerTest {
rocketmqCommon
.
info
(
"common message {}"
,
i
,
new
RuntimeException
());
rocketmqRemoting
.
info
(
"remoting message {}"
,
i
,
new
RuntimeException
());
}
try
{
Thread
.
sleep
(
10
);
}
catch
(
InterruptedException
ignore
)
{
}
String
content
=
MixAll
.
file2String
(
LOG_DIR
+
"/rocketmq_client.log"
);
Assert
.
assertTrue
(
content
.
contains
(
"testClientlog"
));
Assert
.
assertTrue
(
content
.
contains
(
"RocketmqClient"
));
...
...
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimpleProducer.java
浏览文件 @
4fb72cd1
...
...
@@ -69,6 +69,7 @@ public class SimpleProducer {
try
{
countDownLatch
.
await
();
Thread
.
sleep
(
500
);
// Wait some time for one-way delivery.
}
catch
(
InterruptedException
ignore
)
{
}
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/config/ClientConfig.java
浏览文件 @
4fb72cd1
...
...
@@ -20,16 +20,16 @@ import io.openmessaging.OMSBuiltinKeys;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
public
class
ClientConfig
implements
OMSBuiltinKeys
,
NonStandardKeys
{
private
String
omsD
riverImpl
;
private
String
omsA
ccessPoints
;
private
String
omsN
amespace
;
private
String
omsP
roducerId
;
private
String
omsC
onsumerId
;
private
int
o
msO
perationTimeout
=
5000
;
private
String
omsRoutingName
;
private
String
omsOperatorNam
e
;
private
String
omsDstQueue
;
private
String
omsSrcTopic
;
private
String
d
riverImpl
;
private
String
a
ccessPoints
;
private
String
n
amespace
;
private
String
p
roducerId
;
private
String
c
onsumerId
;
private
int
operationTimeout
=
5000
;
private
String
region
;
private
String
routingSourc
e
;
private
String
routingDestination
;
private
String
routingExpression
;
private
String
rmqConsumerGroup
;
private
String
rmqProducerGroup
=
"__OMS_PRODUCER_DEFAULT_GROUP"
;
private
int
rmqMaxRedeliveryTimes
=
16
;
...
...
@@ -40,84 +40,60 @@ public class ClientConfig implements OMSBuiltinKeys, NonStandardKeys {
private
int
rmqPullMessageBatchNums
=
32
;
private
int
rmqPullMessageCacheCapacity
=
1000
;
public
String
get
Oms
DriverImpl
()
{
return
omsD
riverImpl
;
public
String
getDriverImpl
()
{
return
d
riverImpl
;
}
public
void
set
OmsDriverImpl
(
final
String
omsD
riverImpl
)
{
this
.
omsDriverImpl
=
omsD
riverImpl
;
public
void
set
DriverImpl
(
final
String
d
riverImpl
)
{
this
.
driverImpl
=
d
riverImpl
;
}
public
String
get
Oms
AccessPoints
()
{
return
omsA
ccessPoints
;
public
String
getAccessPoints
()
{
return
a
ccessPoints
;
}
public
void
set
OmsAccessPoints
(
final
String
omsA
ccessPoints
)
{
this
.
omsAccessPoints
=
omsA
ccessPoints
;
public
void
set
AccessPoints
(
final
String
a
ccessPoints
)
{
this
.
accessPoints
=
a
ccessPoints
;
}
public
String
get
Oms
Namespace
()
{
return
omsN
amespace
;
public
String
getNamespace
()
{
return
n
amespace
;
}
public
void
set
OmsNamespace
(
final
String
omsN
amespace
)
{
this
.
omsNamespace
=
omsN
amespace
;
public
void
set
Namespace
(
final
String
n
amespace
)
{
this
.
namespace
=
n
amespace
;
}
public
String
get
Oms
ProducerId
()
{
return
omsP
roducerId
;
public
String
getProducerId
()
{
return
p
roducerId
;
}
public
void
set
OmsProducerId
(
final
String
omsP
roducerId
)
{
this
.
omsProducerId
=
omsP
roducerId
;
public
void
set
ProducerId
(
final
String
p
roducerId
)
{
this
.
producerId
=
p
roducerId
;
}
public
String
get
Oms
ConsumerId
()
{
return
omsC
onsumerId
;
public
String
getConsumerId
()
{
return
c
onsumerId
;
}
public
void
set
OmsConsumerId
(
final
String
omsC
onsumerId
)
{
this
.
omsConsumerId
=
omsC
onsumerId
;
public
void
set
ConsumerId
(
final
String
c
onsumerId
)
{
this
.
consumerId
=
c
onsumerId
;
}
public
int
getO
msO
perationTimeout
()
{
return
o
msO
perationTimeout
;
public
int
getOperationTimeout
()
{
return
operationTimeout
;
}
public
void
setO
msOperationTimeout
(
final
int
omsO
perationTimeout
)
{
this
.
o
msOperationTimeout
=
omsO
perationTimeout
;
public
void
setO
perationTimeout
(
final
int
o
perationTimeout
)
{
this
.
o
perationTimeout
=
o
perationTimeout
;
}
public
String
get
OmsRoutingNam
e
()
{
return
omsRoutingNam
e
;
public
String
get
RoutingSourc
e
()
{
return
routingSourc
e
;
}
public
void
setOmsRoutingName
(
final
String
omsRoutingName
)
{
this
.
omsRoutingName
=
omsRoutingName
;
}
public
String
getOmsOperatorName
()
{
return
omsOperatorName
;
}
public
void
setOmsOperatorName
(
final
String
omsOperatorName
)
{
this
.
omsOperatorName
=
omsOperatorName
;
}
public
String
getOmsDstQueue
()
{
return
omsDstQueue
;
}
public
void
setOmsDstQueue
(
final
String
omsDstQueue
)
{
this
.
omsDstQueue
=
omsDstQueue
;
}
public
String
getOmsSrcTopic
()
{
return
omsSrcTopic
;
}
public
void
setOmsSrcTopic
(
final
String
omsSrcTopic
)
{
this
.
omsSrcTopic
=
omsSrcTopic
;
public
void
setRoutingSource
(
final
String
routingSource
)
{
this
.
routingSource
=
routingSource
;
}
public
String
getRmqConsumerGroup
()
{
...
...
@@ -191,4 +167,28 @@ public class ClientConfig implements OMSBuiltinKeys, NonStandardKeys {
public
void
setRmqPullMessageCacheCapacity
(
final
int
rmqPullMessageCacheCapacity
)
{
this
.
rmqPullMessageCacheCapacity
=
rmqPullMessageCacheCapacity
;
}
public
String
getRegion
()
{
return
region
;
}
public
void
setRegion
(
String
region
)
{
this
.
region
=
region
;
}
public
String
getRoutingDestination
()
{
return
routingDestination
;
}
public
void
setRoutingDestination
(
String
routingDestination
)
{
this
.
routingDestination
=
routingDestination
;
}
public
String
getRoutingExpression
()
{
return
routingExpression
;
}
public
void
setRoutingExpression
(
String
routingExpression
)
{
this
.
routingExpression
=
routingExpression
;
}
}
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/LocalMessageCache.java
浏览文件 @
4fb72cd1
...
...
@@ -91,11 +91,11 @@ class LocalMessageCache implements ServiceLifecycle {
}
MessageExt
poll
()
{
return
poll
(
clientConfig
.
getO
msO
perationTimeout
());
return
poll
(
clientConfig
.
getOperationTimeout
());
}
MessageExt
poll
(
final
KeyValue
properties
)
{
int
currentPollTimeout
=
clientConfig
.
getO
msO
perationTimeout
();
int
currentPollTimeout
=
clientConfig
.
getOperationTimeout
();
if
(
properties
.
containsKey
(
Message
.
BuiltinKeys
.
TIMEOUT
))
{
currentPollTimeout
=
properties
.
getInt
(
Message
.
BuiltinKeys
.
TIMEOUT
);
}
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PullConsumerImpl.java
浏览文件 @
4fb72cd1
...
...
@@ -52,7 +52,7 @@ public class PullConsumerImpl implements PullConsumer {
this
.
properties
=
properties
;
this
.
clientConfig
=
BeanUtils
.
populate
(
properties
,
ClientConfig
.
class
);
String
consumerGroup
=
clientConfig
.
get
Oms
ConsumerId
();
String
consumerGroup
=
clientConfig
.
getConsumerId
();
if
(
null
==
consumerGroup
||
consumerGroup
.
isEmpty
())
{
throw
new
OMSRuntimeException
(
"-1"
,
"Consumer Group is necessary for RocketMQ, please set it."
);
}
...
...
@@ -60,7 +60,7 @@ public class PullConsumerImpl implements PullConsumer {
this
.
rocketmqPullConsumer
=
pullConsumerScheduleService
.
getDefaultMQPullConsumer
();
String
accessPoints
=
clientConfig
.
get
Oms
AccessPoints
();
String
accessPoints
=
clientConfig
.
getAccessPoints
();
if
(
accessPoints
==
null
||
accessPoints
.
isEmpty
())
{
throw
new
OMSRuntimeException
(
"-1"
,
"OMS AccessPoints is null or empty."
);
}
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java
浏览文件 @
4fb72cd1
...
...
@@ -52,13 +52,13 @@ public class PushConsumerImpl implements PushConsumer {
this
.
properties
=
properties
;
this
.
clientConfig
=
BeanUtils
.
populate
(
properties
,
ClientConfig
.
class
);
String
accessPoints
=
clientConfig
.
get
Oms
AccessPoints
();
String
accessPoints
=
clientConfig
.
getAccessPoints
();
if
(
accessPoints
==
null
||
accessPoints
.
isEmpty
())
{
throw
new
OMSRuntimeException
(
"-1"
,
"OMS AccessPoints is null or empty."
);
}
this
.
rocketmqPushConsumer
.
setNamesrvAddr
(
accessPoints
.
replace
(
','
,
';'
));
String
consumerGroup
=
clientConfig
.
get
Oms
ConsumerId
();
String
consumerGroup
=
clientConfig
.
getConsumerId
();
if
(
null
==
consumerGroup
||
consumerGroup
.
isEmpty
())
{
throw
new
OMSRuntimeException
(
"-1"
,
"Consumer Group is necessary for RocketMQ, please set it."
);
}
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/AbstractOMSProducer.java
浏览文件 @
4fb72cd1
...
...
@@ -52,7 +52,7 @@ abstract class AbstractOMSProducer implements ServiceLifecycle, MessageFactory {
this
.
rocketmqProducer
=
new
DefaultMQProducer
();
this
.
clientConfig
=
BeanUtils
.
populate
(
properties
,
ClientConfig
.
class
);
String
accessPoints
=
clientConfig
.
get
Oms
AccessPoints
();
String
accessPoints
=
clientConfig
.
getAccessPoints
();
if
(
accessPoints
==
null
||
accessPoints
.
isEmpty
())
{
throw
new
OMSRuntimeException
(
"-1"
,
"OMS AccessPoints is null or empty."
);
}
...
...
@@ -60,7 +60,7 @@ abstract class AbstractOMSProducer implements ServiceLifecycle, MessageFactory {
this
.
rocketmqProducer
.
setProducerGroup
(
clientConfig
.
getRmqProducerGroup
());
String
producerId
=
buildInstanceName
();
this
.
rocketmqProducer
.
setSendMsgTimeout
(
clientConfig
.
getO
msO
perationTimeout
());
this
.
rocketmqProducer
.
setSendMsgTimeout
(
clientConfig
.
getOperationTimeout
());
this
.
rocketmqProducer
.
setInstanceName
(
producerId
);
this
.
rocketmqProducer
.
setMaxMessageSize
(
1024
*
1024
*
4
);
properties
.
put
(
OMSBuiltinKeys
.
PRODUCER_ID
,
producerId
);
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/utils/BeanUtils.java
浏览文件 @
4fb72cd1
...
...
@@ -171,7 +171,7 @@ public final class BeanUtils {
}
String
beanFieldNameWithCapitalization
=
StringUtils
.
join
(
keyGroup
);
try
{
setProperties
(
clazz
,
obj
,
"set
Oms
"
+
beanFieldNameWithCapitalization
,
properties
.
getString
(
key
));
setProperties
(
clazz
,
obj
,
"set"
+
beanFieldNameWithCapitalization
,
properties
.
getString
(
key
));
}
catch
(
NoSuchMethodException
|
IllegalAccessException
|
InvocationTargetException
ignored
)
{
//ignored...
}
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PullConsumerImplTest.java
浏览文件 @
4fb72cd1
...
...
@@ -20,6 +20,7 @@ import io.openmessaging.BytesMessage;
import
io.openmessaging.Message
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.OMS
;
import
io.openmessaging.OMSBuiltinKeys
;
import
io.openmessaging.consumer.PullConsumer
;
import
io.openmessaging.rocketmq.config.ClientConfig
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
...
...
@@ -48,9 +49,9 @@ public class PullConsumerImplTest {
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
.
getMessagingAccessPoint
(
"o
penmessaging
:rocketmq://IP1:9876,IP2:9876/namespace"
);
.
getMessagingAccessPoint
(
"o
ms
:rocketmq://IP1:9876,IP2:9876/namespace"
);
consumer
=
messagingAccessPoint
.
createPullConsumer
(
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"TestGroup"
));
consumer
=
messagingAccessPoint
.
createPullConsumer
(
OMS
.
newKeyValue
().
put
(
OMSBuiltinKeys
.
CONSUMER_ID
,
"TestGroup"
));
consumer
.
attachQueue
(
queueName
);
Field
field
=
PullConsumerImpl
.
class
.
getDeclaredField
(
"rocketmqPullConsumer"
);
...
...
@@ -58,7 +59,7 @@ public class PullConsumerImplTest {
field
.
set
(
consumer
,
rocketmqPullConsumer
);
//Replace
ClientConfig
clientConfig
=
new
ClientConfig
();
clientConfig
.
setO
msO
perationTimeout
(
200
);
clientConfig
.
setOperationTimeout
(
200
);
localMessageCache
=
spy
(
new
LocalMessageCache
(
rocketmqPullConsumer
,
clientConfig
));
field
=
PullConsumerImpl
.
class
.
getDeclaredField
(
"localMessageCache"
);
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/consumer/PushConsumerImplTest.java
浏览文件 @
4fb72cd1
...
...
@@ -18,6 +18,7 @@ package io.openmessaging.rocketmq.consumer;
import
io.openmessaging.BytesMessage
;
import
io.openmessaging.Message
;
import
io.openmessaging.OMSBuiltinKeys
;
import
io.openmessaging.consumer.MessageListener
;
import
io.openmessaging.MessagingAccessPoint
;
import
io.openmessaging.OMS
;
...
...
@@ -47,9 +48,9 @@ public class PushConsumerImplTest {
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
.
getMessagingAccessPoint
(
"o
penmessaging
:rocketmq://IP1:9876,IP2:9876/namespace"
);
.
getMessagingAccessPoint
(
"o
ms
:rocketmq://IP1:9876,IP2:9876/namespace"
);
consumer
=
messagingAccessPoint
.
createPushConsumer
(
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"TestGroup"
));
OMS
.
newKeyValue
().
put
(
OMSBuiltinKeys
.
CONSUMER_ID
,
"TestGroup"
));
Field
field
=
PushConsumerImpl
.
class
.
getDeclaredField
(
"rocketmqPushConsumer"
);
field
.
setAccessible
(
true
);
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/producer/ProducerImplTest.java
浏览文件 @
4fb72cd1
...
...
@@ -50,7 +50,7 @@ public class ProducerImplTest {
@Before
public
void
init
()
throws
NoSuchFieldException
,
IllegalAccessException
{
final
MessagingAccessPoint
messagingAccessPoint
=
OMS
.
getMessagingAccessPoint
(
"o
penmessaging
:rocketmq://IP1:9876,IP2:9876/namespace"
);
.
getMessagingAccessPoint
(
"o
ms
:rocketmq://IP1:9876,IP2:9876/namespace"
);
producer
=
messagingAccessPoint
.
createProducer
();
Field
field
=
AbstractOMSProducer
.
class
.
getDeclaredField
(
"rocketmqProducer"
);
...
...
openmessaging/src/test/java/io/openmessaging/rocketmq/utils/BeanUtilsTest.java
浏览文件 @
4fb72cd1
...
...
@@ -92,9 +92,9 @@ public class BeanUtilsTest {
@Test
public
void
testPopulate_ExistObj
()
{
CustomizedConfig
config
=
new
CustomizedConfig
();
config
.
set
Oms
ConsumerId
(
"NewConsumerId"
);
config
.
setConsumerId
(
"NewConsumerId"
);
Assert
.
assertEquals
(
config
.
get
Oms
ConsumerId
(),
"NewConsumerId"
);
Assert
.
assertEquals
(
config
.
getConsumerId
(),
"NewConsumerId"
);
config
=
BeanUtils
.
populate
(
properties
,
config
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录