Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
9800afb0
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看板
提交
9800afb0
编写于
10月 16, 2019
作者:
Q
qqeasonchen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename REQUEST_UNIQ_ID to CORRELATION_ID
上级
ebc0ede8
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
45 addition
and
46 deletion
+45
-46
client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
.../apache/rocketmq/client/impl/ClientRemotingProcessor.java
+4
-4
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
.../rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+29
-30
client/src/main/java/org/apache/rocketmq/client/producer/RequestFutureTable.java
...g/apache/rocketmq/client/producer/RequestFutureTable.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/producer/RequestResponseFuture.java
...pache/rocketmq/client/producer/RequestResponseFuture.java
+5
-5
client/src/main/java/org/apache/rocketmq/client/utils/MessageUtil.java
...in/java/org/apache/rocketmq/client/utils/MessageUtil.java
+2
-2
common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
...java/org/apache/rocketmq/common/message/MessageConst.java
+2
-2
common/src/main/java/org/apache/rocketmq/common/utils/CorrelationIdUtil.java
...a/org/apache/rocketmq/common/utils/CorrelationIdUtil.java
+2
-2
未找到文件。
client/src/main/java/org/apache/rocketmq/client/impl/ClientRemotingProcessor.java
浏览文件 @
9800afb0
...
...
@@ -280,12 +280,12 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
}
private
void
processReplyMessage
(
MessageExt
replyMsg
)
{
final
String
uniqueId
=
replyMsg
.
getUserProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
RequestResponseFuture
requestResponseFuture
=
RequestFutureTable
.
getRequestFutureTable
().
get
(
unique
Id
);
final
String
correlationId
=
replyMsg
.
getUserProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
final
RequestResponseFuture
requestResponseFuture
=
RequestFutureTable
.
getRequestFutureTable
().
get
(
correlation
Id
);
if
(
requestResponseFuture
!=
null
)
{
requestResponseFuture
.
putResponseMessage
(
replyMsg
);
RequestFutureTable
.
getRequestFutureTable
().
remove
(
unique
Id
);
RequestFutureTable
.
getRequestFutureTable
().
remove
(
correlation
Id
);
if
(
requestResponseFuture
.
getRequestCallback
()
!=
null
)
{
requestResponseFuture
.
getRequestCallback
().
onSuccess
(
replyMsg
);
...
...
@@ -293,7 +293,7 @@ public class ClientRemotingProcessor implements NettyRequestProcessor {
requestResponseFuture
.
putResponseMessage
(
replyMsg
);
}
}
else
{
log
.
warn
(
String
.
format
(
"receive reply message, but not matched any request,
REQUEST_UNIQ_ID: %s"
,
unique
Id
));
log
.
warn
(
String
.
format
(
"receive reply message, but not matched any request,
CorrelationId: %s"
,
correlation
Id
));
}
}
}
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
浏览文件 @
9800afb0
...
...
@@ -85,13 +85,12 @@ import org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHe
import
org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader
;
import
org.apache.rocketmq.common.sysflag.MessageSysFlag
;
import
org.apache.rocketmq.common.utils.
Request
IdUtil
;
import
org.apache.rocketmq.common.utils.
Correlation
IdUtil
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.remoting.RPCHook
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.exception.RemotingConnectException
;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.apache.rocketmq.remoting.exception.RemotingSendRequestException
;
import
org.apache.rocketmq.remoting.exception.RemotingTimeoutException
;
import
org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException
;
...
...
@@ -1341,11 +1340,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
long
timeout
)
throws
RequestTimeoutException
,
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
{
long
beginTimestamp
=
System
.
currentTimeMillis
();
prepareSendRequest
(
msg
,
timeout
);
final
String
requestUniqId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
String
correlationId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
try
{
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
requestUniq
Id
,
timeout
,
null
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
requestUniq
Id
,
requestResponseFuture
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
correlation
Id
,
timeout
,
null
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
correlation
Id
,
requestResponseFuture
);
long
cost
=
System
.
currentTimeMillis
()
-
beginTimestamp
;
this
.
sendDefaultImpl
(
msg
,
CommunicationMode
.
ASYNC
,
new
SendCallback
()
{
...
...
@@ -1373,7 +1372,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
return
responseMessage
;
}
finally
{
RequestFutureTable
.
getRequestFutureTable
().
remove
(
requestUniq
Id
);
RequestFutureTable
.
getRequestFutureTable
().
remove
(
correlation
Id
);
}
}
...
...
@@ -1381,10 +1380,10 @@ public class DefaultMQProducerImpl implements MQProducerInner {
throws
RemotingException
,
InterruptedException
,
MQClientException
,
MQBrokerException
{
long
beginTimestamp
=
System
.
currentTimeMillis
();
prepareSendRequest
(
msg
,
timeout
);
final
String
requestUniqId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
String
correlationId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
requestUniq
Id
,
timeout
,
requestCallback
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
requestUniq
Id
,
requestResponseFuture
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
correlation
Id
,
timeout
,
requestCallback
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
correlation
Id
,
requestResponseFuture
);
long
cost
=
System
.
currentTimeMillis
()
-
beginTimestamp
;
this
.
sendDefaultImpl
(
msg
,
CommunicationMode
.
ASYNC
,
new
SendCallback
()
{
...
...
@@ -1396,7 +1395,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
@Override
public
void
onException
(
Throwable
e
)
{
requestResponseFuture
.
setCause
(
e
);
requestFail
(
requestUniq
Id
);
requestFail
(
correlation
Id
);
}
},
timeout
-
cost
);
}
...
...
@@ -1406,11 +1405,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
InterruptedException
,
RequestTimeoutException
{
long
beginTimestamp
=
System
.
currentTimeMillis
();
prepareSendRequest
(
msg
,
timeout
);
final
String
requestUniqId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
String
correlationId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
try
{
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
requestUniq
Id
,
timeout
,
null
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
requestUniq
Id
,
requestResponseFuture
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
correlation
Id
,
timeout
,
null
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
correlation
Id
,
requestResponseFuture
);
long
cost
=
System
.
currentTimeMillis
()
-
beginTimestamp
;
this
.
sendSelectImpl
(
msg
,
selector
,
arg
,
CommunicationMode
.
ASYNC
,
new
SendCallback
()
{
...
...
@@ -1438,7 +1437,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
return
responseMessage
;
}
finally
{
RequestFutureTable
.
getRequestFutureTable
().
remove
(
requestUniq
Id
);
RequestFutureTable
.
getRequestFutureTable
().
remove
(
correlation
Id
);
}
}
...
...
@@ -1447,10 +1446,10 @@ public class DefaultMQProducerImpl implements MQProducerInner {
throws
RemotingException
,
InterruptedException
,
MQClientException
,
MQBrokerException
{
long
beginTimestamp
=
System
.
currentTimeMillis
();
prepareSendRequest
(
msg
,
timeout
);
final
String
requestUniqId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
String
correlationId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
requestUniq
Id
,
timeout
,
requestCallback
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
requestUniq
Id
,
requestResponseFuture
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
correlation
Id
,
timeout
,
requestCallback
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
correlation
Id
,
requestResponseFuture
);
long
cost
=
System
.
currentTimeMillis
()
-
beginTimestamp
;
this
.
sendSelectImpl
(
msg
,
selector
,
arg
,
CommunicationMode
.
ASYNC
,
new
SendCallback
()
{
...
...
@@ -1462,7 +1461,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
@Override
public
void
onException
(
Throwable
e
)
{
requestResponseFuture
.
setCause
(
e
);
requestFail
(
requestUniq
Id
);
requestFail
(
correlation
Id
);
}
},
timeout
-
cost
);
...
...
@@ -1472,11 +1471,11 @@ public class DefaultMQProducerImpl implements MQProducerInner {
throws
MQClientException
,
RemotingException
,
MQBrokerException
,
InterruptedException
,
RequestTimeoutException
{
long
beginTimestamp
=
System
.
currentTimeMillis
();
prepareSendRequest
(
msg
,
timeout
);
final
String
requestUniqId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
String
correlationId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
try
{
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
requestUniq
Id
,
timeout
,
null
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
requestUniq
Id
,
requestResponseFuture
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
correlation
Id
,
timeout
,
null
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
correlation
Id
,
requestResponseFuture
);
long
cost
=
System
.
currentTimeMillis
()
-
beginTimestamp
;
this
.
sendKernelImpl
(
msg
,
mq
,
CommunicationMode
.
ASYNC
,
new
SendCallback
()
{
...
...
@@ -1504,7 +1503,7 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
return
responseMessage
;
}
finally
{
RequestFutureTable
.
getRequestFutureTable
().
remove
(
requestUniq
Id
);
RequestFutureTable
.
getRequestFutureTable
().
remove
(
correlation
Id
);
}
}
...
...
@@ -1512,10 +1511,10 @@ public class DefaultMQProducerImpl implements MQProducerInner {
throws
RemotingException
,
InterruptedException
,
MQClientException
,
MQBrokerException
{
long
beginTimestamp
=
System
.
currentTimeMillis
();
prepareSendRequest
(
msg
,
timeout
);
final
String
requestUniqId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
final
String
correlationId
=
msg
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
requestUniq
Id
,
timeout
,
requestCallback
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
requestUniq
Id
,
requestResponseFuture
);
final
RequestResponseFuture
requestResponseFuture
=
new
RequestResponseFuture
(
correlation
Id
,
timeout
,
requestCallback
);
RequestFutureTable
.
getRequestFutureTable
().
put
(
correlation
Id
,
requestResponseFuture
);
long
cost
=
System
.
currentTimeMillis
()
-
beginTimestamp
;
this
.
sendKernelImpl
(
msg
,
mq
,
CommunicationMode
.
ASYNC
,
new
SendCallback
()
{
...
...
@@ -1527,13 +1526,13 @@ public class DefaultMQProducerImpl implements MQProducerInner {
@Override
public
void
onException
(
Throwable
e
)
{
requestResponseFuture
.
setCause
(
e
);
requestFail
(
requestUniq
Id
);
requestFail
(
correlation
Id
);
}
},
null
,
timeout
-
cost
);
}
private
void
requestFail
(
final
String
requestUniq
Id
)
{
RequestResponseFuture
responseFuture
=
RequestFutureTable
.
getRequestFutureTable
().
remove
(
requestUniq
Id
);
private
void
requestFail
(
final
String
correlation
Id
)
{
RequestResponseFuture
responseFuture
=
RequestFutureTable
.
getRequestFutureTable
().
remove
(
correlation
Id
);
if
(
responseFuture
!=
null
)
{
responseFuture
.
setSendReqeustOk
(
false
);
responseFuture
.
putResponseMessage
(
null
);
...
...
@@ -1546,9 +1545,9 @@ public class DefaultMQProducerImpl implements MQProducerInner {
}
private
void
prepareSendRequest
(
final
Message
msg
,
long
timeout
)
{
String
requestUniqId
=
RequestIdUtil
.
createUniqueRequest
Id
();
String
correlationId
=
CorrelationIdUtil
.
createCorrelation
Id
();
String
requestClientId
=
this
.
getmQClientFactory
().
getClientId
();
MessageAccessor
.
putProperty
(
msg
,
MessageConst
.
PROPERTY_
REQUEST_UNIQ_ID
,
requestUniq
Id
);
MessageAccessor
.
putProperty
(
msg
,
MessageConst
.
PROPERTY_
CORRELATION_ID
,
correlation
Id
);
MessageAccessor
.
putProperty
(
msg
,
MessageConst
.
PROPERTY_MESSAGE_REPLY_TO
,
requestClientId
);
MessageAccessor
.
putProperty
(
msg
,
MessageConst
.
PROPERTY_MESSAGE_TTL
,
String
.
valueOf
(
timeout
));
...
...
client/src/main/java/org/apache/rocketmq/client/producer/RequestFutureTable.java
浏览文件 @
9800afb0
...
...
@@ -45,7 +45,7 @@ public class RequestFutureTable {
if
(
rep
.
isTimeout
())
{
it
.
remove
();
rfList
.
add
(
rep
);
log
.
warn
(
"remove timeout request,
REQUEST_UNIQ_ID={}"
+
rep
.
getRequestUniq
Id
());
log
.
warn
(
"remove timeout request,
CorrelationId={}"
+
rep
.
getCorrelation
Id
());
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/producer/RequestResponseFuture.java
浏览文件 @
9800afb0
...
...
@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
import
org.apache.rocketmq.common.message.Message
;
public
class
RequestResponseFuture
{
private
final
String
requestUniq
Id
;
private
final
String
correlation
Id
;
private
final
RequestCallback
requestCallback
;
private
final
long
beginTimestamp
=
System
.
currentTimeMillis
();
private
final
Message
requestMsg
=
null
;
...
...
@@ -32,8 +32,8 @@ public class RequestResponseFuture {
private
volatile
boolean
sendRequestOk
=
true
;
private
volatile
Throwable
cause
=
null
;
public
RequestResponseFuture
(
String
requestUniq
Id
,
long
timeoutMillis
,
RequestCallback
requestCallback
)
{
this
.
requestUniqId
=
requestUniq
Id
;
public
RequestResponseFuture
(
String
correlation
Id
,
long
timeoutMillis
,
RequestCallback
requestCallback
)
{
this
.
correlationId
=
correlation
Id
;
this
.
timeoutMillis
=
timeoutMillis
;
this
.
requestCallback
=
requestCallback
;
}
...
...
@@ -63,8 +63,8 @@ public class RequestResponseFuture {
this
.
countDownLatch
.
countDown
();
}
public
String
get
RequestUniq
Id
()
{
return
requestUniq
Id
;
public
String
get
Correlation
Id
()
{
return
correlation
Id
;
}
public
long
getTimeoutMillis
()
{
...
...
client/src/main/java/org/apache/rocketmq/client/utils/MessageUtil.java
浏览文件 @
9800afb0
...
...
@@ -30,14 +30,14 @@ public class MessageUtil {
Message
replyMessage
=
new
Message
();
String
cluster
=
requestMessage
.
getProperty
(
MessageConst
.
PROPERTY_CLUSTER
);
String
replyTo
=
requestMessage
.
getProperty
(
MessageConst
.
PROPERTY_MESSAGE_REPLY_TO
);
String
requestUniqId
=
requestMessage
.
getProperty
(
MessageConst
.
PROPERTY_REQUEST_UNIQ
_ID
);
String
correlationId
=
requestMessage
.
getProperty
(
MessageConst
.
PROPERTY_CORRELATION
_ID
);
String
ttl
=
requestMessage
.
getProperty
(
MessageConst
.
PROPERTY_MESSAGE_TTL
);
replyMessage
.
setBody
(
body
);
if
(
cluster
!=
null
)
{
String
replyTopic
=
MixAll
.
getReplyTopic
(
cluster
);
replyMessage
.
setTopic
(
replyTopic
);
MessageAccessor
.
putProperty
(
replyMessage
,
MessageConst
.
PROPERTY_MESSAGE_TYPE
,
MixAll
.
REPLY_MESSAGE_FLAG
);
MessageAccessor
.
putProperty
(
replyMessage
,
MessageConst
.
PROPERTY_
REQUEST_UNIQ_ID
,
requestUniq
Id
);
MessageAccessor
.
putProperty
(
replyMessage
,
MessageConst
.
PROPERTY_
CORRELATION_ID
,
correlation
Id
);
MessageAccessor
.
putProperty
(
replyMessage
,
MessageConst
.
PROPERTY_MESSAGE_REPLY_TO
,
replyTo
);
MessageAccessor
.
putProperty
(
replyMessage
,
MessageConst
.
PROPERTY_MESSAGE_TTL
,
ttl
);
...
...
common/src/main/java/org/apache/rocketmq/common/message/MessageConst.java
浏览文件 @
9800afb0
...
...
@@ -45,7 +45,7 @@ public class MessageConst {
public
static
final
String
PROPERTY_TRANSACTION_CHECK_TIMES
=
"TRANSACTION_CHECK_TIMES"
;
public
static
final
String
PROPERTY_CHECK_IMMUNITY_TIME_IN_SECONDS
=
"CHECK_IMMUNITY_TIME_IN_SECONDS"
;
public
static
final
String
PROPERTY_INSTANCE_ID
=
"INSTANCE_ID"
;
public
static
final
String
PROPERTY_
REQUEST_UNIQ_ID
=
"REQUEST_UNIQ
_ID"
;
public
static
final
String
PROPERTY_
CORRELATION_ID
=
"CORRELATION
_ID"
;
public
static
final
String
PROPERTY_MESSAGE_REPLY_TO
=
"REPLY_TO"
;
public
static
final
String
PROPERTY_MESSAGE_TTL
=
"TTL"
;
public
static
final
String
PROPERTY_REPLY_MESSAGE_ARRIVE_TIME
=
"ARRIVE_TIME"
;
...
...
@@ -81,7 +81,7 @@ public class MessageConst {
STRING_HASH_SET
.
add
(
PROPERTY_MAX_RECONSUME_TIMES
);
STRING_HASH_SET
.
add
(
PROPERTY_CONSUME_START_TIMESTAMP
);
STRING_HASH_SET
.
add
(
PROPERTY_INSTANCE_ID
);
STRING_HASH_SET
.
add
(
PROPERTY_
REQUEST_UNIQ
_ID
);
STRING_HASH_SET
.
add
(
PROPERTY_
CORRELATION
_ID
);
STRING_HASH_SET
.
add
(
PROPERTY_MESSAGE_REPLY_TO
);
STRING_HASH_SET
.
add
(
PROPERTY_MESSAGE_TTL
);
STRING_HASH_SET
.
add
(
PROPERTY_REPLY_MESSAGE_ARRIVE_TIME
);
...
...
common/src/main/java/org/apache/rocketmq/common/utils/
Request
IdUtil.java
→
common/src/main/java/org/apache/rocketmq/common/utils/
Correlation
IdUtil.java
浏览文件 @
9800afb0
...
...
@@ -19,8 +19,8 @@ package org.apache.rocketmq.common.utils;
import
java.util.UUID
;
public
class
Request
IdUtil
{
public
static
String
create
UniqueRequest
Id
()
{
public
class
Correlation
IdUtil
{
public
static
String
create
Correlation
Id
()
{
return
UUID
.
randomUUID
().
toString
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录