Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
d7cafdf0
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看板
提交
d7cafdf0
编写于
10月 14, 2019
作者:
S
shenhui.backend
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP: compatible with JDK1.6
上级
f28be821
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
27 deletion
+49
-27
broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
...cketmq/broker/processor/AbstractSendMessageProcessor.java
+2
-1
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+2
-1
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
...pache/rocketmq/broker/processor/SendMessageProcessor.java
+5
-0
remoting/pom.xml
remoting/pom.xml
+2
-2
remoting/src/main/java/org/apache/rocketmq/remoting/netty/AsyncNettyRequestProcessor.java
...e/rocketmq/remoting/netty/AsyncNettyRequestProcessor.java
+12
-0
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
...apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
+19
-17
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
...apache/rocketmq/remoting/netty/NettyRequestProcessor.java
+0
-6
remoting/src/main/java/org/apache/rocketmq/remoting/netty/RemotingResponseCallback.java
...che/rocketmq/remoting/netty/RemotingResponseCallback.java
+7
-0
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
浏览文件 @
d7cafdf0
...
...
@@ -49,11 +49,12 @@ import org.apache.rocketmq.logging.InternalLogger;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.exception.RemotingCommandException
;
import
org.apache.rocketmq.remoting.netty.AsyncNettyRequestProcessor
;
import
org.apache.rocketmq.remoting.netty.NettyRequestProcessor
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.store.MessageExtBrokerInner
;
public
abstract
class
AbstractSendMessageProcessor
implements
NettyRequestProcessor
{
public
abstract
class
AbstractSendMessageProcessor
extends
AsyncNettyRequestProcessor
implements
NettyRequestProcessor
{
protected
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
protected
final
static
int
DLQ_NUMS_PER_GROUP
=
1
;
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
d7cafdf0
...
...
@@ -118,6 +118,7 @@ import org.apache.rocketmq.filter.util.BitsArray;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.exception.RemotingCommandException
;
import
org.apache.rocketmq.remoting.exception.RemotingTimeoutException
;
import
org.apache.rocketmq.remoting.netty.AsyncNettyRequestProcessor
;
import
org.apache.rocketmq.remoting.netty.NettyRequestProcessor
;
import
org.apache.rocketmq.remoting.protocol.LanguageCode
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
...
...
@@ -132,7 +133,7 @@ import org.apache.rocketmq.store.PutMessageResult;
import
org.apache.rocketmq.store.PutMessageStatus
;
import
org.apache.rocketmq.store.SelectMappedBufferResult
;
public
class
AdminBrokerProcessor
implements
NettyRequestProcessor
{
public
class
AdminBrokerProcessor
extends
AsyncNettyRequestProcessor
implements
NettyRequestProcessor
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
private
final
BrokerController
brokerController
;
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
浏览文件 @
d7cafdf0
...
...
@@ -50,6 +50,7 @@ import org.apache.rocketmq.common.sysflag.MessageSysFlag;
import
org.apache.rocketmq.common.sysflag.TopicSysFlag
;
import
org.apache.rocketmq.remoting.exception.RemotingCommandException
;
import
org.apache.rocketmq.remoting.netty.NettyRequestProcessor
;
import
org.apache.rocketmq.remoting.netty.RemotingResponseCallback
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.store.MessageExtBrokerInner
;
import
org.apache.rocketmq.store.PutMessageResult
;
...
...
@@ -77,6 +78,10 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
@Override
public
void
asyncProcessRequest
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
,
RemotingResponseCallback
responseCallback
)
throws
Exception
{
asyncProcessRequest
(
ctx
,
request
).
thenAccept
(
responseCallback:
:
callback
);
}
public
CompletableFuture
<
RemotingCommand
>
asyncProcessRequest
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
)
throws
RemotingCommandException
{
final
SendMessageContext
mqtraceContext
;
...
...
remoting/pom.xml
浏览文件 @
d7cafdf0
...
...
@@ -28,8 +28,8 @@
<name>
rocketmq-remoting ${project.version}
</name>
<properties>
<maven.compiler.source>
1.
8
</maven.compiler.source>
<maven.compiler.target>
1.
8
</maven.compiler.target>
<maven.compiler.source>
1.
6
</maven.compiler.source>
<maven.compiler.target>
1.
6
</maven.compiler.target>
</properties>
<dependencies>
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/AsyncNettyRequestProcessor.java
0 → 100644
浏览文件 @
d7cafdf0
package
org.apache.rocketmq.remoting.netty
;
import
io.netty.channel.ChannelHandlerContext
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
public
abstract
class
AsyncNettyRequestProcessor
implements
NettyRequestProcessor
{
public
void
asyncProcessRequest
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
,
RemotingResponseCallback
responseCallback
)
throws
Exception
{
RemotingCommand
response
=
processRequest
(
ctx
,
request
);
responseCallback
.
callback
(
response
);
}
}
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java
浏览文件 @
d7cafdf0
...
...
@@ -29,7 +29,6 @@ import java.util.Iterator;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ExecutorService
;
...
...
@@ -201,25 +200,28 @@ public abstract class NettyRemotingAbstract {
public
void
run
()
{
try
{
doBeforeRpcHooks
(
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()),
cmd
);
CompletableFuture
<
RemotingCommand
>
responseFuture
=
pair
.
getObject1
().
asyncProcessRequest
(
ctx
,
cmd
);
responseFuture
.
thenAccept
((
r
)
->
{
doAfterRpcHooks
(
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()),
cmd
,
r
);
if
(!
cmd
.
isOnewayRPC
())
{
if
(
r
!=
null
)
{
r
.
setOpaque
(
opaque
);
r
.
markResponseType
();
try
{
ctx
.
writeAndFlush
(
r
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"process request over, but response failed"
,
e
);
log
.
error
(
cmd
.
toString
());
log
.
error
(
r
.
toString
());
AsyncNettyRequestProcessor
processor
=
(
AsyncNettyRequestProcessor
)
pair
.
getObject1
();
final
RemotingResponseCallback
callback
=
new
RemotingResponseCallback
()
{
@Override
public
void
callback
(
RemotingCommand
response
)
{
doAfterRpcHooks
(
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()),
cmd
,
response
);
if
(!
cmd
.
isOnewayRPC
())
{
if
(
response
!=
null
)
{
response
.
setOpaque
(
opaque
);
response
.
markResponseType
();
try
{
ctx
.
writeAndFlush
(
response
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"process request over, but response failed"
,
e
);
log
.
error
(
cmd
.
toString
());
log
.
error
(
response
.
toString
());
}
}
else
{
}
}
else
{
}
}
});
};
processor
.
asyncProcessRequest
(
ctx
,
cmd
,
callback
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"process request exception"
,
e
);
log
.
error
(
cmd
.
toString
());
...
...
remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRequestProcessor.java
浏览文件 @
d7cafdf0
...
...
@@ -19,8 +19,6 @@ package org.apache.rocketmq.remoting.netty;
import
io.netty.channel.ChannelHandlerContext
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
java.util.concurrent.CompletableFuture
;
/**
* Common remoting command processor
*/
...
...
@@ -30,8 +28,4 @@ public interface NettyRequestProcessor {
boolean
rejectRequest
();
default
CompletableFuture
<
RemotingCommand
>
asyncProcessRequest
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
)
throws
Exception
{
return
CompletableFuture
.
completedFuture
(
processRequest
(
ctx
,
request
));
}
}
remoting/src/main/java/org/apache/rocketmq/remoting/netty/RemotingResponseCallback.java
0 → 100644
浏览文件 @
d7cafdf0
package
org.apache.rocketmq.remoting.netty
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
public
interface
RemotingResponseCallback
{
void
callback
(
RemotingCommand
response
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录