public interface MQPullConsumer extends MQConsumer
| 限定符和类型 | 方法和说明 |
|---|---|
long |
fetchConsumeOffset(MessageQueue mq,
boolean fromStore)
获取消费进度,返回-1表示出错
|
Set<MessageQueue> |
fetchMessageQueuesInBalance(String topic)
根据topic获取MessageQueue,以均衡方式在组内多个成员之间分配
|
PullResult |
pull(MessageQueue mq,
String subExpression,
long offset,
int maxNums)
指定队列,主动拉取消息,即使没有消息,也立刻返回
|
void |
pull(MessageQueue mq,
String subExpression,
long offset,
int maxNums,
PullCallback pullCallback) |
PullResult |
pullBlockIfNotFound(MessageQueue mq,
String subExpression,
long offset,
int maxNums)
指定队列,主动拉取消息,如果没有消息,则broker阻塞一段时间再返回(时间可配置)
broker阻塞期间,如果有消息,则立刻将消息返回 |
void |
pullBlockIfNotFound(MessageQueue mq,
String subExpression,
long offset,
int maxNums,
PullCallback pullCallback) |
void |
registerMessageQueueListener(String topic,
MessageQueueListener listener)
注册监听队列变化的listener对象
|
void |
shutdown()
关闭服务
|
void |
start()
启动服务
|
void |
updateConsumeOffset(MessageQueue mq,
long offset)
更新消费进度
只是更新Consumer缓存中的数据,如果是广播模式,则定时更新到本地存储 如果是集群模式,则定时更新到远端Broker P.S. |
fetchSubscribeMessageQueues, sendMessageBackcreateTopic, earliestMsgStoreTime, maxOffset, minOffset, queryMessage, searchOffset, viewMessagevoid start()
throws MQClientException
void shutdown()
void registerMessageQueueListener(String topic, MessageQueueListener listener)
topic - listener - 一旦发生变化,客户端会主动回调listener对象PullResult pull(MessageQueue mq, String subExpression, long offset, int maxNums) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, MQBrokerException, InterruptedException
mq - 指定具体要拉取的队列subExpression - 订阅过滤表达式字符串,broker依据此表达式进行过滤。目前只支持或运算offset - 从指定队列哪个位置开始拉取maxNums - 一次最多拉取条数MQClientExceptionInterruptedExceptionMQBrokerExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionvoid pull(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionPullResult pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, MQBrokerException, InterruptedException
mq - 指定具体要拉取的队列subExpression - 订阅过滤表达式字符串,broker依据此表达式进行过滤。目前只支持或运算offset - 从指定队列哪个位置开始拉取maxNums - 一次最多拉取条数InterruptedExceptionMQBrokerExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionMQClientExceptionvoid pullBlockIfNotFound(MessageQueue mq, String subExpression, long offset, int maxNums, PullCallback pullCallback) throws MQClientException, com.alibaba.rocketmq.remoting.exception.RemotingException, InterruptedException
MQClientExceptioncom.alibaba.rocketmq.remoting.exception.RemotingExceptionInterruptedExceptionvoid updateConsumeOffset(MessageQueue mq, long offset) throws MQClientException
mq - offset - MQClientExceptionlong fetchConsumeOffset(MessageQueue mq, boolean fromStore) throws MQClientException
mq - fromStore - MQClientExceptionSet<MessageQueue> fetchMessageQueuesInBalance(String topic) throws MQClientException
topic - 消息TopicMQClientExceptionCopyright © 2012–2013. All rights reserved.