Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
cc7543ff
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
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看板
提交
cc7543ff
编写于
9月 24, 2019
作者:
Q
qqeasonchen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add reply interface to DefaultLitePullConsumer
上级
c434ff43
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
77 addition
and
1 deletion
+77
-1
client/src/main/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumer.java
...che/rocketmq/client/consumer/DefaultLitePullConsumer.java
+51
-0
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java
...tmq/client/impl/consumer/DefaultLitePullConsumerImpl.java
+25
-0
client/src/test/java/org/apache/rocketmq/client/utils/MessageUtilsTest.java
...va/org/apache/rocketmq/client/utils/MessageUtilsTest.java
+1
-1
未找到文件。
client/src/main/java/org/apache/rocketmq/client/consumer/DefaultLitePullConsumer.java
浏览文件 @
cc7543ff
...
...
@@ -22,13 +22,18 @@ import java.util.List;
import
org.apache.rocketmq.client.ClientConfig
;
import
org.apache.rocketmq.client.consumer.rebalance.AllocateMessageQueueAveragely
;
import
org.apache.rocketmq.client.consumer.store.OffsetStore
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.impl.consumer.DefaultLitePullConsumerImpl
;
import
org.apache.rocketmq.client.producer.SendCallback
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.message.Message
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.protocol.heartbeat.MessageModel
;
import
org.apache.rocketmq.remoting.RPCHook
;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
public
class
DefaultLitePullConsumer
extends
ClientConfig
implements
LitePullConsumer
{
...
...
@@ -411,4 +416,50 @@ public class DefaultLitePullConsumer extends ClientConfig implements LitePullCon
public
void
setTopicMetadataCheckIntervalMillis
(
long
topicMetadataCheckIntervalMillis
)
{
this
.
topicMetadataCheckIntervalMillis
=
topicMetadataCheckIntervalMillis
;
}
/**
* send a reply message to the producer of the original request message
* @param requestMsg original request message
* @param replyContent contents of reply message
* @param timeoutMillis
* @return {@link SendResult} instance to inform senders details of the deliverable, say Message ID of the message,
* @throws InterruptedException if the thread is interrupted.
* @throws RemotingException if there is any network-tier error.
* @throws MQClientException if there is any client error.
* @throws MQBrokerException if there is any broker error.
*/
public
SendResult
reply
(
final
Message
requestMsg
,
final
byte
[]
replyContent
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
return
this
.
defaultLitePullConsumerImpl
.
reply
(
requestMsg
,
replyContent
,
timeoutMillis
);
}
/**
* send a reply message to the producer of the original request message asynchronously
* @param requestMsg original request message
* @param replyContent contents of reply message
* @param replyCallback callback to execute on replying completion.
* @param timeoutMillis
* @throws InterruptedException if the thread is interrupted.
* @throws RemotingException if there is any network-tier error.
* @throws MQClientException if there is any client error.
* @throws MQBrokerException if there is any broker error.
*/
public
void
reply
(
final
Message
requestMsg
,
final
byte
[]
replyContent
,
final
SendCallback
replyCallback
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
this
.
defaultLitePullConsumerImpl
.
reply
(
requestMsg
,
replyContent
,
replyCallback
,
timeoutMillis
);
}
/**
* send a reply message to the producer of the original request message oneway
* @param requestMsg original request message
* @param replyContent contents of reply message
* @throws InterruptedException if the thread is interrupted.
* @throws RemotingException if there is any network-tier error.
* @throws MQClientException if there is any client error.
* @throws MQBrokerException if there is any broker error.
*/
public
void
replyOneway
(
final
Message
requestMsg
,
final
byte
[]
replyContent
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
this
.
defaultLitePullConsumerImpl
.
replyOneway
(
requestMsg
,
replyContent
);
}
}
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java
浏览文件 @
cc7543ff
...
...
@@ -53,6 +53,9 @@ import org.apache.rocketmq.client.impl.CommunicationMode;
import
org.apache.rocketmq.client.impl.MQClientManager
;
import
org.apache.rocketmq.client.impl.factory.MQClientInstance
;
import
org.apache.rocketmq.client.log.ClientLogger
;
import
org.apache.rocketmq.client.producer.SendCallback
;
import
org.apache.rocketmq.client.producer.SendResult
;
import
org.apache.rocketmq.client.utils.MessageUtil
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.ServiceState
;
import
org.apache.rocketmq.common.ThreadFactoryImpl
;
...
...
@@ -60,6 +63,7 @@ import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import
org.apache.rocketmq.common.filter.ExpressionType
;
import
org.apache.rocketmq.common.filter.FilterAPI
;
import
org.apache.rocketmq.common.help.FAQUrl
;
import
org.apache.rocketmq.common.message.Message
;
import
org.apache.rocketmq.common.message.MessageExt
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.protocol.NamespaceUtil
;
...
...
@@ -1070,4 +1074,25 @@ public class DefaultLitePullConsumerImpl implements MQConsumerInner {
}
}
@Override
public
SendResult
reply
(
final
Message
requestMsg
,
final
byte
[]
replyContent
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
Message
replyMessage
=
MessageUtil
.
createReplyMessage
(
requestMsg
,
replyContent
);
return
this
.
mQClientFactory
.
getDefaultMQProducer
().
send
(
replyMessage
,
timeoutMillis
);
}
@Override
public
void
reply
(
final
Message
requestMsg
,
final
byte
[]
replyContent
,
final
SendCallback
sendCallback
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
{
Message
replyMessage
=
MessageUtil
.
createReplyMessage
(
requestMsg
,
replyContent
);
this
.
mQClientFactory
.
getDefaultMQProducer
().
send
(
replyMessage
,
sendCallback
,
timeoutMillis
);
}
@Override
public
void
replyOneway
(
final
Message
requestMsg
,
final
byte
[]
replyContent
)
throws
RemotingException
,
MQClientException
,
InterruptedException
{
Message
replyMessage
=
MessageUtil
.
createReplyMessage
(
requestMsg
,
replyContent
);
this
.
mQClientFactory
.
getDefaultMQProducer
().
sendOneway
(
replyMessage
);
}
}
client/src/test/java/org/apache/rocketmq/client/utils/MessageUtilsTest.java
浏览文件 @
cc7543ff
...
...
@@ -45,7 +45,7 @@ public class MessageUtilsTest {
Message
msg
=
MessageUtil
.
createReplyMessage
(
createReplyMessage
(
null
),
new
byte
[]
{
'a'
});
failBecauseExceptionWasNotThrown
(
MQClientException
.
class
);
}
catch
(
MQClientException
e
)
{
assertThat
(
e
).
hasMessageContaining
(
"create reply message fail."
);
assertThat
(
e
).
hasMessageContaining
(
"create reply message fail
, requestMessage error, property["
+
MessageConst
.
PROPERTY_CLUSTER
+
"] is null
."
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录