Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
67ccb7f7
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
266
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看板
未验证
提交
67ccb7f7
编写于
9月 18, 2021
作者:
youlixishia
提交者:
GitHub
9月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2729 from wz2cool/master
[ISSUE #2726] retrying by customizing response code
上级
0de4038f
d6da221d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
14 deletion
+32
-14
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
.../rocketmq/client/impl/producer/DefaultMQProducerImpl.java
+7
-14
client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
...rg/apache/rocketmq/client/producer/DefaultMQProducer.java
+25
-0
未找到文件。
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
浏览文件 @
67ccb7f7
...
@@ -82,7 +82,6 @@ import org.apache.rocketmq.common.message.MessageId;
...
@@ -82,7 +82,6 @@ import org.apache.rocketmq.common.message.MessageId;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.message.MessageType
;
import
org.apache.rocketmq.common.message.MessageType
;
import
org.apache.rocketmq.common.protocol.NamespaceUtil
;
import
org.apache.rocketmq.common.protocol.NamespaceUtil
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.SendMessageRequestHeader
;
...
@@ -643,20 +642,14 @@ public class DefaultMQProducerImpl implements MQProducerInner {
...
@@ -643,20 +642,14 @@ public class DefaultMQProducerImpl implements MQProducerInner {
log
.
warn
(
String
.
format
(
"sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s"
,
invokeID
,
endTimestamp
-
beginTimestampPrev
,
mq
),
e
);
log
.
warn
(
String
.
format
(
"sendKernelImpl exception, resend at once, InvokeID: %s, RT: %sms, Broker: %s"
,
invokeID
,
endTimestamp
-
beginTimestampPrev
,
mq
),
e
);
log
.
warn
(
msg
.
toString
());
log
.
warn
(
msg
.
toString
());
exception
=
e
;
exception
=
e
;
switch
(
e
.
getResponseCode
())
{
if
(
this
.
defaultMQProducer
.
getRetryResponseCodes
().
contains
(
e
.
getResponseCode
()))
{
case
ResponseCode
.
TOPIC_NOT_EXIST
:
continue
;
case
ResponseCode
.
SERVICE_NOT_AVAILABLE
:
}
else
{
case
ResponseCode
.
SYSTEM_ERROR
:
if
(
sendResult
!=
null
)
{
case
ResponseCode
.
NO_PERMISSION
:
return
sendResult
;
case
ResponseCode
.
NO_BUYER_ID
:
}
case
ResponseCode
.
NOT_IN_CURRENT_UNIT
:
continue
;
default
:
if
(
sendResult
!=
null
)
{
return
sendResult
;
}
throw
e
;
throw
e
;
}
}
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
endTimestamp
=
System
.
currentTimeMillis
();
endTimestamp
=
System
.
currentTimeMillis
();
...
...
client/src/main/java/org/apache/rocketmq/client/producer/DefaultMQProducer.java
浏览文件 @
67ccb7f7
...
@@ -16,8 +16,11 @@
...
@@ -16,8 +16,11 @@
*/
*/
package
org.apache.rocketmq.client.producer
;
package
org.apache.rocketmq.client.producer
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.concurrent.CopyOnWriteArraySet
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
org.apache.rocketmq.client.ClientConfig
;
import
org.apache.rocketmq.client.ClientConfig
;
import
org.apache.rocketmq.client.QueryResult
;
import
org.apache.rocketmq.client.QueryResult
;
...
@@ -39,6 +42,7 @@ import org.apache.rocketmq.common.message.MessageDecoder;
...
@@ -39,6 +42,7 @@ import org.apache.rocketmq.common.message.MessageDecoder;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageId
;
import
org.apache.rocketmq.common.message.MessageId
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.topic.TopicValidator
;
import
org.apache.rocketmq.common.topic.TopicValidator
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.remoting.RPCHook
;
import
org.apache.rocketmq.remoting.RPCHook
;
...
@@ -63,6 +67,15 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
...
@@ -63,6 +67,15 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
*/
*/
protected
final
transient
DefaultMQProducerImpl
defaultMQProducerImpl
;
protected
final
transient
DefaultMQProducerImpl
defaultMQProducerImpl
;
private
final
InternalLogger
log
=
ClientLogger
.
getLog
();
private
final
InternalLogger
log
=
ClientLogger
.
getLog
();
private
final
Set
<
Integer
>
retryResponseCodes
=
new
CopyOnWriteArraySet
<
Integer
>(
Arrays
.
asList
(
ResponseCode
.
TOPIC_NOT_EXIST
,
ResponseCode
.
SERVICE_NOT_AVAILABLE
,
ResponseCode
.
SYSTEM_ERROR
,
ResponseCode
.
NO_PERMISSION
,
ResponseCode
.
NO_BUYER_ID
,
ResponseCode
.
NOT_IN_CURRENT_UNIT
));
/**
/**
* Producer group conceptually aggregates all producer instances of exactly same role, which is particularly
* Producer group conceptually aggregates all producer instances of exactly same role, which is particularly
* important when transactional messages are involved. </p>
* important when transactional messages are involved. </p>
...
@@ -958,6 +971,15 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
...
@@ -958,6 +971,15 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
this
.
defaultMQProducerImpl
.
setAsyncSenderExecutor
(
asyncSenderExecutor
);
this
.
defaultMQProducerImpl
.
setAsyncSenderExecutor
(
asyncSenderExecutor
);
}
}
/**
* Add response code for retrying.
*
* @param responseCode response code, {@link ResponseCode}
*/
public
void
addRetryResponseCode
(
int
responseCode
)
{
this
.
retryResponseCodes
.
add
(
responseCode
);
}
private
MessageBatch
batch
(
Collection
<
Message
>
msgs
)
throws
MQClientException
{
private
MessageBatch
batch
(
Collection
<
Message
>
msgs
)
throws
MQClientException
{
MessageBatch
msgBatch
;
MessageBatch
msgBatch
;
try
{
try
{
...
@@ -1088,4 +1110,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
...
@@ -1088,4 +1110,7 @@ public class DefaultMQProducer extends ClientConfig implements MQProducer {
return
traceDispatcher
;
return
traceDispatcher
;
}
}
public
Set
<
Integer
>
getRetryResponseCodes
()
{
return
retryResponseCodes
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录