public class DefaultMQPullConsumer extends ClientConfig implements MQPullConsumer
Modifier and Type | Field and Description |
---|---|
protected DefaultMQPullConsumerImpl |
defaultMQPullConsumerImpl |
SEND_MESSAGE_WITH_VIP_CHANNEL_PROPERTY
Constructor and Description |
---|
DefaultMQPullConsumer() |
DefaultMQPullConsumer(RPCHook rpcHook) |
DefaultMQPullConsumer(java.lang.String consumerGroup) |
DefaultMQPullConsumer(java.lang.String consumerGroup,
RPCHook rpcHook) |
Modifier and Type | Method and Description |
---|---|
void |
createTopic(java.lang.String key,
java.lang.String newTopic,
int queueNum)
Creates an topic
|
void |
createTopic(java.lang.String key,
java.lang.String newTopic,
int queueNum,
int topicSysFlag)
Creates an topic
|
long |
earliestMsgStoreTime(MessageQueue mq)
Gets the earliest stored message time
|
long |
fetchConsumeOffset(MessageQueue mq,
boolean fromStore)
Fetch the offset
|
java.util.Set<MessageQueue> |
fetchMessageQueuesInBalance(java.lang.String topic)
Fetch the message queues according to the topic
|
java.util.Set<MessageQueue> |
fetchSubscribeMessageQueues(java.lang.String topic)
Fetch message queues from consumer cache according to the topic
|
AllocateMessageQueueStrategy |
getAllocateMessageQueueStrategy() |
long |
getBrokerSuspendMaxTimeMillis() |
java.lang.String |
getConsumerGroup() |
long |
getConsumerPullTimeoutMillis() |
long |
getConsumerTimeoutMillisWhenSuspend() |
DefaultMQPullConsumerImpl |
getDefaultMQPullConsumerImpl() |
int |
getMaxReconsumeTimes() |
MessageModel |
getMessageModel() |
MessageQueueListener |
getMessageQueueListener() |
OffsetStore |
getOffsetStore() |
java.util.Set<java.lang.String> |
getRegisterTopics() |
boolean |
isUnitMode() |
long |
maxOffset(MessageQueue mq)
Gets the max offset
|
long |
minOffset(MessageQueue mq)
Gets the minimum offset
|
PullResult |
pull(MessageQueue mq,
java.lang.String subExpression,
long offset,
int maxNums)
Pulling the messages,not blocking
|
PullResult |
pull(MessageQueue mq,
java.lang.String subExpression,
long offset,
int maxNums,
long timeout)
Pulling the messages in the specified timeout
|
void |
pull(MessageQueue mq,
java.lang.String subExpression,
long offset,
int maxNums,
PullCallback pullCallback)
Pulling the messages in a async. way
|
void |
pull(MessageQueue mq,
java.lang.String subExpression,
long offset,
int maxNums,
PullCallback pullCallback,
long timeout)
Pulling the messages in a async. way
|
PullResult |
pullBlockIfNotFound(MessageQueue mq,
java.lang.String subExpression,
long offset,
int maxNums)
Pulling the messages,if no message arrival,blocking some time
|
void |
pullBlockIfNotFound(MessageQueue mq,
java.lang.String subExpression,
long offset,
int maxNums,
PullCallback pullCallback)
Pulling the messages through callback function,if no message arrival,blocking.
|
QueryResult |
queryMessage(java.lang.String topic,
java.lang.String key,
int maxNum,
long begin,
long end)
Query messages
|
void |
registerMessageQueueListener(java.lang.String topic,
MessageQueueListener listener)
Register the message queue listener
|
long |
searchOffset(MessageQueue mq,
long timestamp)
Gets the message queue offset according to some time in milliseconds
be cautious to call because of more IO overhead |
void |
sendMessageBack(MessageExt msg,
int delayLevel)
If consuming failure,message will be send back to the brokers,and delay consuming some time
|
void |
sendMessageBack(MessageExt msg,
int delayLevel,
java.lang.String brokerName)
If consuming failure,message will be send back to the broker,and delay consuming some time
|
void |
sendMessageBack(MessageExt msg,
int delayLevel,
java.lang.String brokerName,
java.lang.String consumerGroup)
If consuming failure,message will be send back to the broker,and delay consuming in some time later.
|
void |
setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy) |
void |
setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis) |
void |
setConsumerGroup(java.lang.String consumerGroup) |
void |
setConsumerPullTimeoutMillis(long consumerPullTimeoutMillis) |
void |
setConsumerTimeoutMillisWhenSuspend(long consumerTimeoutMillisWhenSuspend) |
void |
setMaxReconsumeTimes(int maxReconsumeTimes) |
void |
setMessageModel(MessageModel messageModel) |
void |
setMessageQueueListener(MessageQueueListener messageQueueListener) |
void |
setOffsetStore(OffsetStore offsetStore) |
void |
setRegisterTopics(java.util.Set<java.lang.String> registerTopics) |
void |
setUnitMode(boolean isUnitMode) |
void |
shutdown()
Shutdown the consumer
|
void |
start()
Start the consumer
|
void |
updateConsumeOffset(MessageQueue mq,
long offset)
Update the offset
|
MessageExt |
viewMessage(java.lang.String offsetMsgId)
Query message according tto message id
|
MessageExt |
viewMessage(java.lang.String topic,
java.lang.String uniqKey) |
buildMQClientId, changeInstanceNameToPID, cloneClientConfig, getClientCallbackExecutorThreads, getClientIP, getHeartbeatBrokerInterval, getInstanceName, getNamesrvAddr, getPersistConsumerOffsetInterval, getPollNameServerInterval, getUnitName, isVipChannelEnabled, resetClientConfig, setClientCallbackExecutorThreads, setClientIP, setHeartbeatBrokerInterval, setInstanceName, setNamesrvAddr, setPersistConsumerOffsetInterval, setPollNameServerInterval, setUnitName, setVipChannelEnabled, toString
protected final transient DefaultMQPullConsumerImpl defaultMQPullConsumerImpl
public DefaultMQPullConsumer()
public DefaultMQPullConsumer(java.lang.String consumerGroup, RPCHook rpcHook)
public DefaultMQPullConsumer(java.lang.String consumerGroup)
public DefaultMQPullConsumer(RPCHook rpcHook)
public void createTopic(java.lang.String key, java.lang.String newTopic, int queueNum) throws MQClientException
MQAdmin
createTopic
in interface MQAdmin
key
- accesskeynewTopic
- topic namequeueNum
- topic's queue numberMQClientException
public void createTopic(java.lang.String key, java.lang.String newTopic, int queueNum, int topicSysFlag) throws MQClientException
MQAdmin
createTopic
in interface MQAdmin
key
- accesskeynewTopic
- topic namequeueNum
- topic's queue numbertopicSysFlag
- topic system flagMQClientException
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException
MQAdmin
searchOffset
in interface MQAdmin
mq
- Instance of MessageQueuetimestamp
- from when in milliseconds.MQClientException
public long maxOffset(MessageQueue mq) throws MQClientException
MQAdmin
maxOffset
in interface MQAdmin
mq
- Instance of MessageQueueMQClientException
public long minOffset(MessageQueue mq) throws MQClientException
MQAdmin
minOffset
in interface MQAdmin
mq
- Instance of MessageQueueMQClientException
public long earliestMsgStoreTime(MessageQueue mq) throws MQClientException
MQAdmin
earliestMsgStoreTime
in interface MQAdmin
mq
- Instance of MessageQueueMQClientException
public MessageExt viewMessage(java.lang.String offsetMsgId) throws RemotingException, MQBrokerException, java.lang.InterruptedException, MQClientException
MQAdmin
viewMessage
in interface MQAdmin
offsetMsgId
- message idRemotingException
MQBrokerException
java.lang.InterruptedException
MQClientException
public QueryResult queryMessage(java.lang.String topic, java.lang.String key, int maxNum, long begin, long end) throws MQClientException, java.lang.InterruptedException
MQAdmin
queryMessage
in interface MQAdmin
topic
- message topickey
- message key index wordmaxNum
- max message numberbegin
- from whenend
- to whenMQClientException
java.lang.InterruptedException
public AllocateMessageQueueStrategy getAllocateMessageQueueStrategy()
public void setAllocateMessageQueueStrategy(AllocateMessageQueueStrategy allocateMessageQueueStrategy)
public long getBrokerSuspendMaxTimeMillis()
public void setBrokerSuspendMaxTimeMillis(long brokerSuspendMaxTimeMillis)
public java.lang.String getConsumerGroup()
public void setConsumerGroup(java.lang.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 java.util.Set<java.lang.String> getRegisterTopics()
public void setRegisterTopics(java.util.Set<java.lang.String> registerTopics)
public void sendMessageBack(MessageExt msg, int delayLevel) throws RemotingException, MQBrokerException, java.lang.InterruptedException, MQClientException
MQConsumer
sendMessageBack
in interface MQConsumer
RemotingException
MQBrokerException
java.lang.InterruptedException
MQClientException
public void sendMessageBack(MessageExt msg, int delayLevel, java.lang.String brokerName) throws RemotingException, MQBrokerException, java.lang.InterruptedException, MQClientException
MQConsumer
sendMessageBack
in interface MQConsumer
RemotingException
MQBrokerException
java.lang.InterruptedException
MQClientException
public java.util.Set<MessageQueue> fetchSubscribeMessageQueues(java.lang.String topic) throws MQClientException
MQConsumer
fetchSubscribeMessageQueues
in interface MQConsumer
topic
- message topicMQClientException
public void start() throws MQClientException
MQPullConsumer
start
in interface MQPullConsumer
MQClientException
public void shutdown()
MQPullConsumer
shutdown
in interface MQPullConsumer
public void registerMessageQueueListener(java.lang.String topic, MessageQueueListener listener)
MQPullConsumer
registerMessageQueueListener
in interface MQPullConsumer
public PullResult pull(MessageQueue mq, java.lang.String subExpression, long offset, int maxNums) throws MQClientException, RemotingException, MQBrokerException, java.lang.InterruptedException
MQPullConsumer
pull
in interface MQPullConsumer
mq
- from which message queuesubExpression
- subscription expression.it only support or operation such as "tag1 || tag2 || tag3" offset
- from where to pullmaxNums
- max pulling numbersPullRequest
MQClientException
RemotingException
MQBrokerException
java.lang.InterruptedException
public PullResult pull(MessageQueue mq, java.lang.String subExpression, long offset, int maxNums, long timeout) throws MQClientException, RemotingException, MQBrokerException, java.lang.InterruptedException
MQPullConsumer
pull
in interface MQPullConsumer
PullRequest
MQClientException
RemotingException
MQBrokerException
java.lang.InterruptedException
public void pull(MessageQueue mq, java.lang.String subExpression, long offset, int maxNums, PullCallback pullCallback) throws MQClientException, RemotingException, java.lang.InterruptedException
MQPullConsumer
pull
in interface MQPullConsumer
MQClientException
RemotingException
java.lang.InterruptedException
public void pull(MessageQueue mq, java.lang.String subExpression, long offset, int maxNums, PullCallback pullCallback, long timeout) throws MQClientException, RemotingException, java.lang.InterruptedException
MQPullConsumer
pull
in interface MQPullConsumer
MQClientException
RemotingException
java.lang.InterruptedException
public PullResult pullBlockIfNotFound(MessageQueue mq, java.lang.String subExpression, long offset, int maxNums) throws MQClientException, RemotingException, MQBrokerException, java.lang.InterruptedException
MQPullConsumer
pullBlockIfNotFound
in interface MQPullConsumer
PullRequest
MQClientException
RemotingException
MQBrokerException
java.lang.InterruptedException
public void pullBlockIfNotFound(MessageQueue mq, java.lang.String subExpression, long offset, int maxNums, PullCallback pullCallback) throws MQClientException, RemotingException, java.lang.InterruptedException
MQPullConsumer
pullBlockIfNotFound
in interface MQPullConsumer
MQClientException
RemotingException
java.lang.InterruptedException
public void updateConsumeOffset(MessageQueue mq, long offset) throws MQClientException
MQPullConsumer
updateConsumeOffset
in interface MQPullConsumer
MQClientException
public long fetchConsumeOffset(MessageQueue mq, boolean fromStore) throws MQClientException
MQPullConsumer
fetchConsumeOffset
in interface MQPullConsumer
MQClientException
public java.util.Set<MessageQueue> fetchMessageQueuesInBalance(java.lang.String topic) throws MQClientException
MQPullConsumer
fetchMessageQueuesInBalance
in interface MQPullConsumer
topic
- message topicMQClientException
public MessageExt viewMessage(java.lang.String topic, java.lang.String uniqKey) throws RemotingException, MQBrokerException, java.lang.InterruptedException, MQClientException
viewMessage
in interface MQAdmin
MessageExt
of given msgIdRemotingException
MQBrokerException
java.lang.InterruptedException
MQClientException
public void sendMessageBack(MessageExt msg, int delayLevel, java.lang.String brokerName, java.lang.String consumerGroup) throws RemotingException, MQBrokerException, java.lang.InterruptedException, MQClientException
MQPullConsumer
sendMessageBack
in interface MQPullConsumer
RemotingException
MQBrokerException
java.lang.InterruptedException
MQClientException
public OffsetStore getOffsetStore()
public void setOffsetStore(OffsetStore offsetStore)
public DefaultMQPullConsumerImpl getDefaultMQPullConsumerImpl()
public boolean isUnitMode()
isUnitMode
in class ClientConfig
public void setUnitMode(boolean isUnitMode)
setUnitMode
in class ClientConfig
public int getMaxReconsumeTimes()
public void setMaxReconsumeTimes(int maxReconsumeTimes)