com.alibaba.rocketmq.client.impl
类 MQClientAPIImpl

java.lang.Object
  继承者 com.alibaba.rocketmq.client.impl.MQClientAPIImpl

public class MQClientAPIImpl
extends Object

封装所有与服务器通信部分API

从以下版本开始:
2013-7-24
作者:
shijia.wxr

构造方法摘要
MQClientAPIImpl(NettyClientConfig nettyClientConfig, ClientRemotingProcessor clientRemotingProcessor)
           
 
方法摘要
 void consumerSendMessageBack(MessageExt msg, String consumerGroup, int delayLevel, long timeoutMillis)
          失败的消息发回Broker
 void createSubscriptionGroup(String addr, SubscriptionGroupConfig config, long timeoutMillis)
           
 void createTopic(String addr, String defaultTopic, TopicConfig topicConfig, long timeoutMillis)
           
 void deleteKVConfigByValue(String namespace, String projectGroup, long timeoutMillis)
          Name Server: 删除 value 对应的所有 key
 void deleteKVConfigValue(String namespace, String key, long timeoutMillis)
          Name Server: 添加KV配置
 void deleteSubscriptionGroup(String addr, String groupName, long timeoutMillis)
           
 void deleteTopicInBroker(String addr, String topic, long timeoutMillis)
           
 void deleteTopicInNameServer(String addr, String topic, long timeoutMillis)
           
 void endTransactionOneway(String addr, EndTransactionRequestHeader requestHeader, String remark, long timeoutMillis)
          提交或者回滚事务
 String fetchNameServerAddr()
           
 ClusterInfo getBrokerClusterInfo(long timeoutMillis)
          Name Server: 从Name Server获取集群信息
 KVTable getBrokerRuntimeInfo(String addr, long timeoutMillis)
           
 ConsumerConnection getConsumerConnectionList(String addr, String consumerGroup, long timeoutMillis)
          根据ConsumerGroup获取Consumer连接列表以及订阅关系
 List<String> getConsumerIdListByGroup(String addr, String consumerGroup, long timeoutMillis)
          获取某个组的Consumer Id列表
 ConsumeStats getConsumeStats(String addr, String consumerGroup, long timeoutMillis)
           
 TopicRouteData getDefaultTopicRouteInfoFromNameServer(String topic, long timeoutMillis)
          Name Server: 从Name Server获取 Default Topic 路由信息
 long getEarliestMsgStoretime(String addr, String topic, int queueId, long timeoutMillis)
          获取队列的最早时间
 String getKVConfigByValue(String namespace, String value, long timeoutMillis)
          Name Server: 通过 value 获取所有的 key 信息
 String getKVConfigValue(String namespace, String key, long timeoutMillis)
          Name Server: 从Namesrv获取KV配置
 KVTable getKVListByNamespace(String namespace, long timeoutMillis)
          Name Server: 获取指定Namespace下的所有KV
 long getMaxOffset(String addr, String topic, int queueId, long timeoutMillis)
          获取队列的最大Offset
 long getMinOffset(String addr, String topic, int queueId, long timeoutMillis)
          获取队列的最小Offset
 List<String> getNameServerAddressList()
           
 ProducerConnection getProducerConnectionList(String addr, String producerGroup, long timeoutMillis)
          根据ProducerGroup获取Producer连接列表
 String getProjectGroupByIp(String ip, long timeoutMillis)
          Name Server: 通过 server ip 获取 project 信息
 String getProjectGroupPrefix()
           
 RemotingClient getRemotingClient()
           
 SessionCredentials getSessionCredentials()
           
 TopicList getTopicListFromNameServer(long timeoutMillis)
          Name Server: 从Name Server获取所有Topic列表
 TopicRouteData getTopicRouteInfoFromNameServer(String topic, long timeoutMillis)
          Name Server: 从Name Server获取Topic路由信息
 TopicList getTopicsByCluster(String cluster, long timeoutMillis)
          Name Server: 获取指定集群下的所有 topic
 TopicStatsTable getTopicStatsInfo(String addr, String topic, long timeoutMillis)
           
 Map<String,Map<MessageQueue,Long>> invokeBrokerToGetConsumerStatus(String addr, String topic, String group, String clientAddr, long timeoutMillis)
          通知 broker 客户端订阅消息处理
 Map<MessageQueue,Long> invokeBrokerToResetOffset(String addr, String topic, String group, long timestamp, boolean isForce, long timeoutMillis)
          通知 broker 重置 offset
 Set<MessageQueue> lockBatchMQ(String addr, LockBatchRequestBody requestBody, long timeoutMillis)
           
 PullResult pullMessage(String addr, PullMessageRequestHeader requestHeader, long timeoutMillis, CommunicationMode communicationMode, PullCallback pullCallback)
          拉消息接口
 void putKVConfigValue(String namespace, String key, String value, long timeoutMillis)
          Name Server: 添加KV配置
 long queryConsumerOffset(String addr, QueryConsumerOffsetRequestHeader requestHeader, long timeoutMillis)
          查询Consumer消费进度
 void queryMessage(String addr, QueryMessageRequestHeader requestHeader, long timeoutMillis, InvokeCallback invokeCallback)
          查询消息
 GroupList queryTopicConsumeByWho(String addr, String topic, long timeoutMillis)
          根据ConsumerGroup获取Consumer连接列表以及订阅关系
 boolean registerClient(String addr, HeartbeatData heartbeat, long timeoutMillis)
           
 long searchOffset(String addr, String topic, int queueId, long timestamp, long timeoutMillis)
          根据时间查询Offset
 void sendHearbeat(String addr, HeartbeatData heartbeatData, long timeoutMillis)
          发送心跳
 SendResult sendMessage(String addr, String brokerName, Message msg, SendMessageRequestHeader requestHeader, long timeoutMillis, CommunicationMode communicationMode, SendCallback sendCallback)
          发送消息
 void setSessionCredentials(SessionCredentials sessionCredentials)
           
 void shutdown()
           
 void start()
           
 void unlockBatchMQ(String addr, UnlockBatchRequestBody requestBody, long timeoutMillis, boolean oneway)
           
 void unregisterClient(String addr, String clientID, String producerGroup, String consumerGroup, long timeoutMillis)
          发送心跳
 void updateBrokerConfig(String addr, Properties properties, long timeoutMillis)
          更新Broker的配置文件
 void updateConsumerOffset(String addr, UpdateConsumerOffsetRequestHeader requestHeader, long timeoutMillis)
          更新Consumer消费进度
 void updateConsumerOffsetOneway(String addr, UpdateConsumerOffsetRequestHeader requestHeader, long timeoutMillis)
          更新Consumer消费进度
 void updateNameServerAddressList(String addrs)
           
 MessageExt viewMessage(String addr, long phyoffset, long timeoutMillis)
          根据时间查询Offset
 int wipeWritePermOfBroker(String namesrvAddr, String brokerName, long timeoutMillis)
          Name Server: Broker下线前,清除Broker对应的权限
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

MQClientAPIImpl

public MQClientAPIImpl(NettyClientConfig nettyClientConfig,
                       ClientRemotingProcessor clientRemotingProcessor)
方法详细信息

getProjectGroupPrefix

public String getProjectGroupPrefix()

getNameServerAddressList

public List<String> getNameServerAddressList()

getRemotingClient

public RemotingClient getRemotingClient()

fetchNameServerAddr

public String fetchNameServerAddr()

updateNameServerAddressList

public void updateNameServerAddressList(String addrs)

start

public void start()

shutdown

public void shutdown()

createSubscriptionGroup

public void createSubscriptionGroup(String addr,
                                    SubscriptionGroupConfig config,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQBrokerException,
                                    InterruptedException,
                                    MQClientException
抛出:
RemotingException
MQBrokerException
InterruptedException
MQClientException

createTopic

public void createTopic(String addr,
                        String defaultTopic,
                        TopicConfig topicConfig,
                        long timeoutMillis)
                 throws RemotingException,
                        MQBrokerException,
                        InterruptedException,
                        MQClientException
抛出:
RemotingException
MQBrokerException
InterruptedException
MQClientException

sendMessage

public SendResult sendMessage(String addr,
                              String brokerName,
                              Message msg,
                              SendMessageRequestHeader requestHeader,
                              long timeoutMillis,
                              CommunicationMode communicationMode,
                              SendCallback sendCallback)
                       throws RemotingException,
                              MQBrokerException,
                              InterruptedException
发送消息

抛出:
RemotingException
MQBrokerException
InterruptedException

pullMessage

public PullResult pullMessage(String addr,
                              PullMessageRequestHeader requestHeader,
                              long timeoutMillis,
                              CommunicationMode communicationMode,
                              PullCallback pullCallback)
                       throws RemotingException,
                              MQBrokerException,
                              InterruptedException
拉消息接口

抛出:
RemotingException
MQBrokerException
InterruptedException

viewMessage

public MessageExt viewMessage(String addr,
                              long phyoffset,
                              long timeoutMillis)
                       throws RemotingException,
                              MQBrokerException,
                              InterruptedException
根据时间查询Offset

抛出:
RemotingException
MQBrokerException
InterruptedException

searchOffset

public long searchOffset(String addr,
                         String topic,
                         int queueId,
                         long timestamp,
                         long timeoutMillis)
                  throws RemotingException,
                         MQBrokerException,
                         InterruptedException
根据时间查询Offset

抛出:
RemotingException
MQBrokerException
InterruptedException

getMaxOffset

public long getMaxOffset(String addr,
                         String topic,
                         int queueId,
                         long timeoutMillis)
                  throws RemotingException,
                         MQBrokerException,
                         InterruptedException
获取队列的最大Offset

抛出:
RemotingException
MQBrokerException
InterruptedException

getConsumerIdListByGroup

public List<String> getConsumerIdListByGroup(String addr,
                                             String consumerGroup,
                                             long timeoutMillis)
                                      throws RemotingConnectException,
                                             RemotingSendRequestException,
                                             RemotingTimeoutException,
                                             MQBrokerException,
                                             InterruptedException
获取某个组的Consumer Id列表

抛出:
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
MQBrokerException
InterruptedException

getMinOffset

public long getMinOffset(String addr,
                         String topic,
                         int queueId,
                         long timeoutMillis)
                  throws RemotingException,
                         MQBrokerException,
                         InterruptedException
获取队列的最小Offset

抛出:
RemotingException
MQBrokerException
InterruptedException

getEarliestMsgStoretime

public long getEarliestMsgStoretime(String addr,
                                    String topic,
                                    int queueId,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQBrokerException,
                                    InterruptedException
获取队列的最早时间

抛出:
RemotingException
MQBrokerException
InterruptedException

queryConsumerOffset

public long queryConsumerOffset(String addr,
                                QueryConsumerOffsetRequestHeader requestHeader,
                                long timeoutMillis)
                         throws RemotingException,
                                MQBrokerException,
                                InterruptedException
查询Consumer消费进度

抛出:
RemotingException
MQBrokerException
InterruptedException

updateConsumerOffset

public void updateConsumerOffset(String addr,
                                 UpdateConsumerOffsetRequestHeader requestHeader,
                                 long timeoutMillis)
                          throws RemotingException,
                                 MQBrokerException,
                                 InterruptedException
更新Consumer消费进度

抛出:
RemotingException
MQBrokerException
InterruptedException

updateConsumerOffsetOneway

public void updateConsumerOffsetOneway(String addr,
                                       UpdateConsumerOffsetRequestHeader requestHeader,
                                       long timeoutMillis)
                                throws RemotingConnectException,
                                       RemotingTooMuchRequestException,
                                       RemotingTimeoutException,
                                       RemotingSendRequestException,
                                       InterruptedException
更新Consumer消费进度

抛出:
InterruptedException
RemotingSendRequestException
RemotingTimeoutException
RemotingTooMuchRequestException
RemotingConnectException

sendHearbeat

public void sendHearbeat(String addr,
                         HeartbeatData heartbeatData,
                         long timeoutMillis)
                  throws RemotingException,
                         MQBrokerException,
                         InterruptedException
发送心跳

抛出:
RemotingException
MQBrokerException
InterruptedException

unregisterClient

public void unregisterClient(String addr,
                             String clientID,
                             String producerGroup,
                             String consumerGroup,
                             long timeoutMillis)
                      throws RemotingException,
                             MQBrokerException,
                             InterruptedException
发送心跳

抛出:
RemotingException
MQBrokerException
InterruptedException

endTransactionOneway

public void endTransactionOneway(String addr,
                                 EndTransactionRequestHeader requestHeader,
                                 String remark,
                                 long timeoutMillis)
                          throws RemotingException,
                                 MQBrokerException,
                                 InterruptedException
提交或者回滚事务

抛出:
RemotingException
MQBrokerException
InterruptedException

queryMessage

public void queryMessage(String addr,
                         QueryMessageRequestHeader requestHeader,
                         long timeoutMillis,
                         InvokeCallback invokeCallback)
                  throws RemotingException,
                         MQBrokerException,
                         InterruptedException
查询消息

抛出:
RemotingException
MQBrokerException
InterruptedException

registerClient

public boolean registerClient(String addr,
                              HeartbeatData heartbeat,
                              long timeoutMillis)
                       throws RemotingException,
                              InterruptedException
抛出:
RemotingException
InterruptedException

consumerSendMessageBack

public void consumerSendMessageBack(MessageExt msg,
                                    String consumerGroup,
                                    int delayLevel,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQBrokerException,
                                    InterruptedException
失败的消息发回Broker

抛出:
RemotingException
MQBrokerException
InterruptedException

lockBatchMQ

public Set<MessageQueue> lockBatchMQ(String addr,
                                     LockBatchRequestBody requestBody,
                                     long timeoutMillis)
                              throws RemotingException,
                                     MQBrokerException,
                                     InterruptedException
抛出:
RemotingException
MQBrokerException
InterruptedException

unlockBatchMQ

public void unlockBatchMQ(String addr,
                          UnlockBatchRequestBody requestBody,
                          long timeoutMillis,
                          boolean oneway)
                   throws RemotingException,
                          MQBrokerException,
                          InterruptedException
抛出:
RemotingException
MQBrokerException
InterruptedException

getTopicStatsInfo

public TopicStatsTable getTopicStatsInfo(String addr,
                                         String topic,
                                         long timeoutMillis)
                                  throws InterruptedException,
                                         RemotingTimeoutException,
                                         RemotingSendRequestException,
                                         RemotingConnectException,
                                         MQBrokerException
抛出:
InterruptedException
RemotingTimeoutException
RemotingSendRequestException
RemotingConnectException
MQBrokerException

getConsumeStats

public ConsumeStats getConsumeStats(String addr,
                                    String consumerGroup,
                                    long timeoutMillis)
                             throws InterruptedException,
                                    RemotingTimeoutException,
                                    RemotingSendRequestException,
                                    RemotingConnectException,
                                    MQBrokerException
抛出:
InterruptedException
RemotingTimeoutException
RemotingSendRequestException
RemotingConnectException
MQBrokerException

getProducerConnectionList

public ProducerConnection getProducerConnectionList(String addr,
                                                    String producerGroup,
                                                    long timeoutMillis)
                                             throws RemotingConnectException,
                                                    RemotingSendRequestException,
                                                    RemotingTimeoutException,
                                                    InterruptedException,
                                                    MQBrokerException
根据ProducerGroup获取Producer连接列表

抛出:
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
InterruptedException
MQBrokerException

getConsumerConnectionList

public ConsumerConnection getConsumerConnectionList(String addr,
                                                    String consumerGroup,
                                                    long timeoutMillis)
                                             throws RemotingConnectException,
                                                    RemotingSendRequestException,
                                                    RemotingTimeoutException,
                                                    InterruptedException,
                                                    MQBrokerException
根据ConsumerGroup获取Consumer连接列表以及订阅关系

抛出:
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
InterruptedException
MQBrokerException

getBrokerRuntimeInfo

public KVTable getBrokerRuntimeInfo(String addr,
                                    long timeoutMillis)
                             throws RemotingConnectException,
                                    RemotingSendRequestException,
                                    RemotingTimeoutException,
                                    InterruptedException,
                                    MQBrokerException
抛出:
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
InterruptedException
MQBrokerException

updateBrokerConfig

public void updateBrokerConfig(String addr,
                               Properties properties,
                               long timeoutMillis)
                        throws RemotingConnectException,
                               RemotingSendRequestException,
                               RemotingTimeoutException,
                               InterruptedException,
                               MQBrokerException,
                               UnsupportedEncodingException
更新Broker的配置文件

参数:
addr -
properties -
timeoutMillis -
抛出:
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
InterruptedException
MQBrokerException
UnsupportedEncodingException

getBrokerClusterInfo

public ClusterInfo getBrokerClusterInfo(long timeoutMillis)
                                 throws InterruptedException,
                                        RemotingTimeoutException,
                                        RemotingSendRequestException,
                                        RemotingConnectException,
                                        MQBrokerException
Name Server: 从Name Server获取集群信息

抛出:
InterruptedException
RemotingTimeoutException
RemotingSendRequestException
RemotingConnectException
MQBrokerException

getDefaultTopicRouteInfoFromNameServer

public TopicRouteData getDefaultTopicRouteInfoFromNameServer(String topic,
                                                             long timeoutMillis)
                                                      throws RemotingException,
                                                             MQClientException,
                                                             InterruptedException
Name Server: 从Name Server获取 Default Topic 路由信息

抛出:
RemotingException
MQClientException
InterruptedException

getTopicRouteInfoFromNameServer

public TopicRouteData getTopicRouteInfoFromNameServer(String topic,
                                                      long timeoutMillis)
                                               throws RemotingException,
                                                      MQClientException,
                                                      InterruptedException
Name Server: 从Name Server获取Topic路由信息

抛出:
RemotingException
MQClientException
InterruptedException

getTopicListFromNameServer

public TopicList getTopicListFromNameServer(long timeoutMillis)
                                     throws RemotingException,
                                            MQClientException,
                                            InterruptedException
Name Server: 从Name Server获取所有Topic列表

抛出:
RemotingException
MQClientException
InterruptedException

wipeWritePermOfBroker

public int wipeWritePermOfBroker(String namesrvAddr,
                                 String brokerName,
                                 long timeoutMillis)
                          throws RemotingCommandException,
                                 RemotingConnectException,
                                 RemotingSendRequestException,
                                 RemotingTimeoutException,
                                 InterruptedException,
                                 MQClientException
Name Server: Broker下线前,清除Broker对应的权限

抛出:
RemotingCommandException
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
InterruptedException
MQClientException

deleteTopicInBroker

public void deleteTopicInBroker(String addr,
                                String topic,
                                long timeoutMillis)
                         throws RemotingException,
                                MQBrokerException,
                                InterruptedException,
                                MQClientException
抛出:
RemotingException
MQBrokerException
InterruptedException
MQClientException

deleteTopicInNameServer

public void deleteTopicInNameServer(String addr,
                                    String topic,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQBrokerException,
                                    InterruptedException,
                                    MQClientException
抛出:
RemotingException
MQBrokerException
InterruptedException
MQClientException

deleteSubscriptionGroup

public void deleteSubscriptionGroup(String addr,
                                    String groupName,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQBrokerException,
                                    InterruptedException,
                                    MQClientException
抛出:
RemotingException
MQBrokerException
InterruptedException
MQClientException

getKVConfigValue

public String getKVConfigValue(String namespace,
                               String key,
                               long timeoutMillis)
                        throws RemotingException,
                               MQClientException,
                               InterruptedException
Name Server: 从Namesrv获取KV配置

抛出:
RemotingException
MQClientException
InterruptedException

putKVConfigValue

public void putKVConfigValue(String namespace,
                             String key,
                             String value,
                             long timeoutMillis)
                      throws RemotingException,
                             MQClientException,
                             InterruptedException
Name Server: 添加KV配置

抛出:
RemotingException
MQClientException
InterruptedException

deleteKVConfigValue

public void deleteKVConfigValue(String namespace,
                                String key,
                                long timeoutMillis)
                         throws RemotingException,
                                MQClientException,
                                InterruptedException
Name Server: 添加KV配置

抛出:
RemotingException
MQClientException
InterruptedException

getProjectGroupByIp

public String getProjectGroupByIp(String ip,
                                  long timeoutMillis)
                           throws RemotingException,
                                  MQClientException,
                                  InterruptedException
Name Server: 通过 server ip 获取 project 信息

抛出:
RemotingException
MQClientException
InterruptedException

getKVConfigByValue

public String getKVConfigByValue(String namespace,
                                 String value,
                                 long timeoutMillis)
                          throws RemotingException,
                                 MQClientException,
                                 InterruptedException
Name Server: 通过 value 获取所有的 key 信息

抛出:
RemotingException
MQClientException
InterruptedException

getKVListByNamespace

public KVTable getKVListByNamespace(String namespace,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQClientException,
                                    InterruptedException
Name Server: 获取指定Namespace下的所有KV

抛出:
RemotingException
MQClientException
InterruptedException

deleteKVConfigByValue

public void deleteKVConfigByValue(String namespace,
                                  String projectGroup,
                                  long timeoutMillis)
                           throws RemotingException,
                                  MQClientException,
                                  InterruptedException
Name Server: 删除 value 对应的所有 key

抛出:
RemotingException
MQClientException
InterruptedException

invokeBrokerToResetOffset

public Map<MessageQueue,Long> invokeBrokerToResetOffset(String addr,
                                                        String topic,
                                                        String group,
                                                        long timestamp,
                                                        boolean isForce,
                                                        long timeoutMillis)
                                                 throws RemotingException,
                                                        MQClientException,
                                                        InterruptedException
通知 broker 重置 offset

抛出:
RemotingException
MQClientException
InterruptedException

invokeBrokerToGetConsumerStatus

public Map<String,Map<MessageQueue,Long>> invokeBrokerToGetConsumerStatus(String addr,
                                                                          String topic,
                                                                          String group,
                                                                          String clientAddr,
                                                                          long timeoutMillis)
                                                                   throws RemotingException,
                                                                          MQClientException,
                                                                          InterruptedException
通知 broker 客户端订阅消息处理

抛出:
RemotingException
MQClientException
InterruptedException

queryTopicConsumeByWho

public GroupList queryTopicConsumeByWho(String addr,
                                        String topic,
                                        long timeoutMillis)
                                 throws RemotingConnectException,
                                        RemotingSendRequestException,
                                        RemotingTimeoutException,
                                        InterruptedException,
                                        MQBrokerException
根据ConsumerGroup获取Consumer连接列表以及订阅关系

抛出:
RemotingConnectException
RemotingSendRequestException
RemotingTimeoutException
InterruptedException
MQBrokerException

getSessionCredentials

public SessionCredentials getSessionCredentials()

setSessionCredentials

public void setSessionCredentials(SessionCredentials sessionCredentials)

getTopicsByCluster

public TopicList getTopicsByCluster(String cluster,
                                    long timeoutMillis)
                             throws RemotingException,
                                    MQClientException,
                                    InterruptedException
Name Server: 获取指定集群下的所有 topic

抛出:
RemotingException
MQClientException
InterruptedException


Copyright © 2012-2014. All Rights Reserved.