|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.alibaba.rocketmq.client.ClientConfig
com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer
public class DefaultMQPullConsumer
消费者,主动拉取方式消费
| 字段摘要 | |
|---|---|
protected DefaultMQPullConsumerImpl |
defaultMQPullConsumerImpl
|
| 构造方法摘要 | |
|---|---|
DefaultMQPullConsumer()
|
|
DefaultMQPullConsumer(String consumerGroup)
|
|
| 方法摘要 | |
|---|---|
void |
createTopic(String key,
String newTopic,
int queueNum)
创建topic |
long |
earliestMsgStoreTime(MessageQueue mq)
向服务器查询队列保存的最早消息对应的存储时间 |
long |
fetchConsumeOffset(MessageQueue mq,
boolean fromStore)
获取消费进度,返回-1表示出错 |
Set<MessageQueue> |
fetchMessageQueuesInBalance(String topic)
根据topic获取MessageQueue,以均衡方式在组内多个成员之间分配 |
Set<MessageQueue> |
fetchSubscribeMessageQueues(String topic)
根据topic获取对应的MessageQueue,是可被订阅的队列 P.S 从Consumer Cache中拿数据,可以频繁调用。 |
AllocateMessageQueueStrategy |
getAllocateMessageQueueStrategy()
|
long |
getBrokerSuspendMaxTimeMillis()
|
String |
getConsumerGroup()
|
long |
getConsumerPullTimeoutMillis()
|
long |
getConsumerTimeoutMillisWhenSuspend()
|
DefaultMQPullConsumerImpl |
getDefaultMQPullConsumerImpl()
|
MessageModel |
getMessageModel()
|
MessageQueueListener |
getMessageQueueListener()
|
OffsetStore |
getOffsetStore()
|
Set<String> |
getRegisterTopics()
|
boolean |
isUnitMode()
|
long |
maxOffset(MessageQueue mq)
向服务器查询队列最大Offset PS: 最大Offset无对应消息,减1有消息 |
long |
minOffset(MessageQueue mq)
向服务器查询队列最小Offset PS: 最小Offset有对应消息 |
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)
|
QueryResult |
queryMessage(String topic,
String key,
int maxNum,
long begin,
long end)
根据消息Key查询消息 |
void |
registerMessageQueueListener(String topic,
MessageQueueListener listener)
注册监听队列变化的listener对象 |
long |
searchOffset(MessageQueue mq,
long timestamp)
根据时间查询对应的offset,精确到毫秒 P.S. |
void |
sendMessageBack(MessageExt msg,
int delayLevel)
Consumer消费失败的消息可以选择重新发回到服务器端,并延时消费 会首先尝试将消息发回到消息之前存储的主机,此时只传送消息Offset,消息体不传送,不会占用网络带宽 如果发送失败,会自动重试发往其他主机,此时消息体也会传送 重传回去的消息只会被当前Consumer Group消费。 |
void |
setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy)
|
void |
setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis)
|
void |
setConsumerGroup(String consumerGroup)
|
void |
setConsumerPullTimeoutMillis(long consumerPullTimeoutMillis)
|
void |
setConsumerTimeoutMillisWhenSuspend(long consumerTimeoutMillisWhenSuspend)
|
void |
setMessageModel(MessageModel messageModel)
|
void |
setMessageQueueListener(MessageQueueListener messageQueueListener)
|
void |
setOffsetStore(OffsetStore offsetStore)
|
void |
setRegisterTopics(Set<String> registerTopics)
|
void |
setUnitMode(boolean isUnitMode)
|
void |
shutdown()
关闭服务 |
void |
start()
启动服务 |
void |
updateConsumeOffset(MessageQueue mq,
long offset)
更新消费进度 只是更新Consumer缓存中的数据,如果是广播模式,则定时更新到本地存储 如果是集群模式,则定时更新到远端Broker P.S. |
MessageExt |
viewMessage(String msgId)
根据消息ID,从服务器获取完整的消息 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 字段详细信息 |
|---|
protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl
| 构造方法详细信息 |
|---|
public DefaultMQPullConsumer()
public DefaultMQPullConsumer(String consumerGroup)
| 方法详细信息 |
|---|
public void createTopic(String key,
String newTopic,
int queueNum)
throws MQClientException
MQAdmin 复制的描述
MQAdmin 中的 createTopickey - 请向运维人员申请newTopic - 要创建的新topicqueueNum - 新topic队列数
MQClientException
public long searchOffset(MessageQueue mq,
long timestamp)
throws MQClientException
MQAdmin 复制的描述
MQAdmin 中的 searchOffsetmq - 队列timestamp - 毫秒形式时间戳
MQClientException
public long maxOffset(MessageQueue mq)
throws MQClientException
MQAdmin 复制的描述
MQAdmin 中的 maxOffsetmq - 队列
MQClientException
public long minOffset(MessageQueue mq)
throws MQClientException
MQAdmin 复制的描述
MQAdmin 中的 minOffsetmq - 队列
MQClientException
public long earliestMsgStoreTime(MessageQueue mq)
throws MQClientException
MQAdmin 复制的描述
MQAdmin 中的 earliestMsgStoreTimemq - 队列
MQClientException
public MessageExt viewMessage(String msgId)
throws RemotingException,
MQBrokerException,
InterruptedException,
MQClientException
MQAdmin 复制的描述
MQAdmin 中的 viewMessageRemotingException
MQBrokerException
InterruptedException
MQClientException
public QueryResult queryMessage(String topic,
String key,
int maxNum,
long begin,
long end)
throws MQClientException,
InterruptedException
MQAdmin 复制的描述
MQAdmin 中的 queryMessagetopic - 消息主题key - 消息关键词maxNum - 查询最大条数begin - 起始时间戳end - 结束时间戳
MQClientException
InterruptedExceptionpublic AllocateMessageQueueStrategy getAllocateMessageQueueStrategy()
public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy)
public long getBrokerSuspendMaxTimeMillis()
public void setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis)
public String getConsumerGroup()
public void setConsumerGroup(String consumerGroup)
public long getConsumerPullTimeoutMillis()
public void setConsumerPullTimeoutMillis(long consumerPullTimeoutMillis)
public long getConsumerTimeoutMillisWhenSuspend()
public void setConsumerTimeoutMillisWhenSuspend(long consumerTimeoutMillisWhenSuspend)
public MessageModel getMessageModel()
public void setMessageModel(MessageModel messageModel)
public MessageQueueListener getMessageQueueListener()
public void setMessageQueueListener(MessageQueueListener messageQueueListener)
public Set<String> getRegisterTopics()
public void setRegisterTopics(Set<String> registerTopics)
public void sendMessageBack(MessageExt msg,
int delayLevel)
throws RemotingException,
MQBrokerException,
InterruptedException,
MQClientException
MQConsumer 复制的描述
MQConsumer 中的 sendMessageBackRemotingException
MQBrokerException
InterruptedException
MQClientException
public Set<MessageQueue> fetchSubscribeMessageQueues(String topic)
throws MQClientException
MQConsumer 复制的描述
MQConsumer 中的 fetchSubscribeMessageQueuestopic - 消息Topic
MQClientException
public void start()
throws MQClientException
MQPullConsumer 复制的描述
MQPullConsumer 中的 startMQClientExceptionpublic void shutdown()
MQPullConsumer 复制的描述
MQPullConsumer 中的 shutdown
public void registerMessageQueueListener(String topic,
MessageQueueListener listener)
MQPullConsumer 复制的描述
MQPullConsumer 中的 registerMessageQueueListenerlistener - 一旦发生变化,客户端会主动回调listener对象
public PullResult pull(MessageQueue mq,
String subExpression,
long offset,
int maxNums)
throws MQClientException,
RemotingException,
MQBrokerException,
InterruptedException
MQPullConsumer 复制的描述
MQPullConsumer 中的 pullmq - 指定具体要拉取的队列subExpression - 订阅过滤表达式字符串,broker依据此表达式进行过滤。目前只支持或运算offset - 从指定队列哪个位置开始拉取maxNums - 一次最多拉取条数
MQClientException
RemotingException
MQBrokerException
InterruptedException
public void pull(MessageQueue mq,
String subExpression,
long offset,
int maxNums,
PullCallback pullCallback)
throws MQClientException,
RemotingException,
InterruptedException
MQPullConsumer 中的 pullMQClientException
RemotingException
InterruptedException
public PullResult pullBlockIfNotFound(MessageQueue mq,
String subExpression,
long offset,
int maxNums)
throws MQClientException,
RemotingException,
MQBrokerException,
InterruptedException
MQPullConsumer 复制的描述
MQPullConsumer 中的 pullBlockIfNotFoundmq - 指定具体要拉取的队列subExpression - 订阅过滤表达式字符串,broker依据此表达式进行过滤。目前只支持或运算offset - 从指定队列哪个位置开始拉取maxNums - 一次最多拉取条数
MQClientException
RemotingException
MQBrokerException
InterruptedException
public void pullBlockIfNotFound(MessageQueue mq,
String subExpression,
long offset,
int maxNums,
PullCallback pullCallback)
throws MQClientException,
RemotingException,
InterruptedException
MQPullConsumer 中的 pullBlockIfNotFoundMQClientException
RemotingException
InterruptedException
public void updateConsumeOffset(MessageQueue mq,
long offset)
throws MQClientException
MQPullConsumer 复制的描述
MQPullConsumer 中的 updateConsumeOffsetMQClientException
public long fetchConsumeOffset(MessageQueue mq,
boolean fromStore)
throws MQClientException
MQPullConsumer 复制的描述
MQPullConsumer 中的 fetchConsumeOffsetMQClientException
public Set<MessageQueue> fetchMessageQueuesInBalance(String topic)
throws MQClientException
MQPullConsumer 复制的描述
MQPullConsumer 中的 fetchMessageQueuesInBalancetopic - 消息Topic
MQClientExceptionpublic OffsetStore getOffsetStore()
public void setOffsetStore(OffsetStore offsetStore)
public DefaultMQPullConsumerImpl getDefaultMQPullConsumerImpl()
public boolean isUnitMode()
public void setUnitMode(boolean isUnitMode)
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||