Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
b7ec4121
R
Rocketmq
项目概览
小五666\n哈哈
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
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看板
提交
b7ec4121
编写于
4月 24, 2017
作者:
Y
yukon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OpenMessaging code reformat.
上级
6edeb831
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
32 addition
and
25 deletion
+32
-25
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimpleProducer.java
...apache/rocketmq/example/openmessaging/SimpleProducer.java
+10
-8
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimplePullConsumer.java
...he/rocketmq/example/openmessaging/SimplePullConsumer.java
+3
-3
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimplePushConsumer.java
...he/rocketmq/example/openmessaging/SimplePushConsumer.java
+3
-3
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/LocalMessageCache.java
...io/openmessaging/rocketmq/consumer/LocalMessageCache.java
+0
-1
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java
.../io/openmessaging/rocketmq/consumer/PushConsumerImpl.java
+3
-3
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/AbstractOMSProducer.java
.../openmessaging/rocketmq/producer/AbstractOMSProducer.java
+1
-1
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/ProducerImpl.java
...java/io/openmessaging/rocketmq/producer/ProducerImpl.java
+1
-1
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/SequenceProducerImpl.java
...openmessaging/rocketmq/producer/SequenceProducerImpl.java
+1
-1
openmessaging/src/main/java/io/openmessaging/rocketmq/promise/DefaultPromise.java
...ava/io/openmessaging/rocketmq/promise/DefaultPromise.java
+1
-1
openmessaging/src/main/java/io/openmessaging/rocketmq/promise/FutureState.java
...n/java/io/openmessaging/rocketmq/promise/FutureState.java
+9
-3
未找到文件。
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimpleProducer.java
浏览文件 @
b7ec4121
...
...
@@ -33,10 +33,10 @@ public class SimpleProducer {
final
Producer
producer
=
messagingAccessPoint
.
createProducer
();
messagingAccessPoint
.
startup
();
System
.
out
.
print
ln
(
"messagingAccessPoint startup OK
"
);
System
.
out
.
print
f
(
"MessagingAccessPoint startup OK%n
"
);
producer
.
startup
();
System
.
out
.
print
ln
(
"producer startup OK
"
);
System
.
out
.
print
f
(
"Producer startup OK%n
"
);
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -50,25 +50,27 @@ public class SimpleProducer {
Message
message
=
producer
.
createBytesMessageToTopic
(
"OMS_HELLO_TOPIC"
,
"OMS_HELLO_BODY"
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)));
SendResult
sendResult
=
producer
.
send
(
message
);
//final Void aVoid = result.get(3000L);
System
.
out
.
print
ln
(
"send async message OK, msgId: "
+
sendResult
.
messageId
());
System
.
out
.
print
f
(
"Send async message OK, msgId: %s%n"
,
sendResult
.
messageId
());
}
{
final
Promise
<
SendResult
>
result
=
producer
.
sendAsync
(
producer
.
createBytesMessageToTopic
(
"OMS_HELLO_TOPIC"
,
"OMS_HELLO_BODY"
.
getBytes
(
Charset
.
forName
(
"UTF-8"
))));
result
.
addListener
(
new
PromiseListener
<
SendResult
>()
{
@Override
public
void
operationCompleted
(
Promise
<
SendResult
>
promise
)
{
System
.
out
.
println
(
"Send async message OK, msgId: "
+
promise
.
get
().
messageId
());
@Override
public
void
operationCompleted
(
Promise
<
SendResult
>
promise
)
{
System
.
out
.
printf
(
"Send async message OK, msgId: %s%n"
,
promise
.
get
().
messageId
());
}
@Override
public
void
operationFailed
(
Promise
<
SendResult
>
promise
)
{
System
.
out
.
println
(
"send async message Failed, error: "
+
promise
.
getThrowable
().
getMessage
());
@Override
public
void
operationFailed
(
Promise
<
SendResult
>
promise
)
{
System
.
out
.
printf
(
"Send async message Failed, error: %s%n"
,
promise
.
getThrowable
().
getMessage
());
}
});
}
{
producer
.
sendOneway
(
producer
.
createBytesMessageToTopic
(
"OMS_HELLO_TOPIC"
,
"OMS_HELLO_BODY"
.
getBytes
(
Charset
.
forName
(
"UTF-8"
))));
System
.
out
.
print
ln
(
"Send oneway message OK
"
);
System
.
out
.
print
f
(
"Send oneway message OK%n
"
);
}
}
}
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimplePullConsumer.java
浏览文件 @
b7ec4121
...
...
@@ -33,7 +33,7 @@ public class SimplePullConsumer {
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"OMS_CONSUMER"
));
messagingAccessPoint
.
startup
();
System
.
out
.
print
ln
(
"messagingAccessPoint startup OK
"
);
System
.
out
.
print
f
(
"MessagingAccessPoint startup OK%n
"
);
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -44,13 +44,13 @@ public class SimplePullConsumer {
}));
consumer
.
startup
();
System
.
out
.
print
ln
(
"consumer startup OK
"
);
System
.
out
.
print
f
(
"Consumer startup OK%n
"
);
while
(
true
)
{
Message
message
=
consumer
.
poll
();
if
(
message
!=
null
)
{
String
msgId
=
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
);
System
.
out
.
print
ln
(
"Received one message: "
+
msgId
);
System
.
out
.
print
f
(
"Received one message: %s%n"
,
msgId
);
consumer
.
ack
(
msgId
);
}
}
...
...
example/src/main/java/org/apache/rocketmq/example/openmessaging/SimplePushConsumer.java
浏览文件 @
b7ec4121
...
...
@@ -35,7 +35,7 @@ public class SimplePushConsumer {
createPushConsumer
(
OMS
.
newKeyValue
().
put
(
NonStandardKeys
.
CONSUMER_GROUP
,
"OMS_CONSUMER"
));
messagingAccessPoint
.
startup
();
System
.
out
.
print
ln
(
"messagingAccessPoint startup OK
"
);
System
.
out
.
print
f
(
"MessagingAccessPoint startup OK%n
"
);
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
new
Runnable
()
{
@Override
...
...
@@ -48,12 +48,12 @@ public class SimplePushConsumer {
consumer
.
attachQueue
(
"OMS_HELLO_TOPIC"
,
new
MessageListener
()
{
@Override
public
void
onMessage
(
final
Message
message
,
final
ReceivedMessageContext
context
)
{
System
.
out
.
print
ln
(
"Received one message: "
+
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
));
System
.
out
.
print
f
(
"Received one message: %s%n"
,
message
.
headers
().
getString
(
MessageHeader
.
MESSAGE_ID
));
context
.
ack
();
}
});
consumer
.
startup
();
System
.
out
.
print
ln
(
"consumer startup OK
"
);
System
.
out
.
print
f
(
"Consumer startup OK%n
"
);
}
}
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/LocalMessageCache.java
浏览文件 @
b7ec4121
...
...
@@ -175,7 +175,6 @@ class LocalMessageCache implements ServiceLifecycle {
try
{
if
(!
msgTreeMap
.
isEmpty
())
{
msg
=
msgTreeMap
.
firstEntry
().
getValue
();
System
.
out
.
println
(
msg
);
if
(
System
.
currentTimeMillis
()
-
Long
.
parseLong
(
MessageAccessor
.
getConsumeStartTimeStamp
(
msg
))
>
clientConfig
.
getRmqMessageConsumeTimeout
()
*
60
*
1000
)
{
//Expired, ack and remove it.
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java
浏览文件 @
b7ec4121
...
...
@@ -25,9 +25,9 @@ import io.openmessaging.PushConsumer;
import
io.openmessaging.ReceivedMessageContext
;
import
io.openmessaging.exception.OMSRuntimeException
;
import
io.openmessaging.rocketmq.config.ClientConfig
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
import
io.openmessaging.rocketmq.utils.BeanUtils
;
import
io.openmessaging.rocketmq.utils.OMSUtil
;
import
io.openmessaging.rocketmq.domain.NonStandardKeys
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -47,7 +47,6 @@ public class PushConsumerImpl implements PushConsumer {
private
final
Map
<
String
,
MessageListener
>
subscribeTable
=
new
ConcurrentHashMap
<>();
private
final
ClientConfig
clientConfig
;
public
PushConsumerImpl
(
final
KeyValue
properties
)
{
this
.
rocketmqPushConsumer
=
new
DefaultMQPushConsumer
();
this
.
properties
=
properties
;
...
...
@@ -130,7 +129,8 @@ public class PushConsumerImpl implements PushConsumer {
class
MessageListenerImpl
implements
MessageListenerConcurrently
{
@Override
public
ConsumeConcurrentlyStatus
consumeMessage
(
List
<
MessageExt
>
rmqMsgList
,
ConsumeConcurrentlyContext
contextRMQ
)
{
public
ConsumeConcurrentlyStatus
consumeMessage
(
List
<
MessageExt
>
rmqMsgList
,
ConsumeConcurrentlyContext
contextRMQ
)
{
MessageExt
rmqMsg
=
rmqMsgList
.
get
(
0
);
BytesMessage
omsMsg
=
OMSUtil
.
msgConvert
(
rmqMsg
);
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/AbstractOMSProducer.java
浏览文件 @
b7ec4121
...
...
@@ -41,7 +41,7 @@ import org.slf4j.Logger;
import
static
io
.
openmessaging
.
rocketmq
.
utils
.
OMSUtil
.
buildInstanceName
;
abstract
class
AbstractOMSProducer
implements
ServiceLifecycle
,
MessageFactory
{
abstract
class
AbstractOMSProducer
implements
ServiceLifecycle
,
MessageFactory
{
final
static
Logger
log
=
ClientLogger
.
getLog
();
final
KeyValue
properties
;
final
DefaultMQProducer
rocketmqProducer
;
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/ProducerImpl.java
浏览文件 @
b7ec4121
...
...
@@ -25,8 +25,8 @@ import io.openmessaging.Promise;
import
io.openmessaging.PropertyKeys
;
import
io.openmessaging.SendResult
;
import
io.openmessaging.exception.OMSRuntimeException
;
import
io.openmessaging.rocketmq.utils.OMSUtil
;
import
io.openmessaging.rocketmq.promise.DefaultPromise
;
import
io.openmessaging.rocketmq.utils.OMSUtil
;
import
org.apache.rocketmq.client.producer.SendCallback
;
import
org.apache.rocketmq.client.producer.SendStatus
;
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/producer/SequenceProducerImpl.java
浏览文件 @
b7ec4121
...
...
@@ -78,7 +78,7 @@ public class SequenceProducerImpl extends AbstractOMSProducer implements Sequenc
try
{
SendResult
sendResult
=
this
.
rocketmqProducer
.
send
(
rmqMessages
);
String
[]
msgIdArray
=
sendResult
.
getMsgId
().
split
(
","
);
String
[]
msgIdArray
=
sendResult
.
getMsgId
().
split
(
","
);
for
(
int
i
=
0
;
i
<
messages
.
size
();
i
++)
{
Message
message
=
messages
.
get
(
i
);
message
.
headers
().
put
(
MessageHeader
.
MESSAGE_ID
,
msgIdArray
[
i
]);
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/promise/DefaultPromise.java
浏览文件 @
b7ec4121
...
...
@@ -77,7 +77,7 @@ public class DefaultPromise<V> implements Promise<V> {
}
else
{
long
waitTime
=
timeout
-
(
System
.
currentTimeMillis
()
-
createTime
);
if
(
waitTime
>
0
)
{
for
(;
;
)
{
for
(;;
)
{
try
{
lock
.
wait
(
waitTime
);
}
catch
(
InterruptedException
e
)
{
...
...
openmessaging/src/main/java/io/openmessaging/rocketmq/promise/FutureState.java
浏览文件 @
b7ec4121
...
...
@@ -18,11 +18,17 @@
package
io.openmessaging.rocketmq.promise
;
public
enum
FutureState
{
/** the task is doing **/
/**
* the task is doing
**/
DOING
(
0
),
/** the task is done **/
/**
* the task is done
**/
DONE
(
1
),
/** ths task is cancelled **/
/**
* ths task is cancelled
**/
CANCELLED
(
2
);
public
final
int
value
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录