Search in sources :

Example 36 with ConsumerConnection

use of org.apache.rocketmq.common.protocol.body.ConsumerConnection in project rocketmq by apache.

the class DefaultMQAdminExtImpl method examineConsumerConnectionInfo.

@Override
public ConsumerConnection examineConsumerConnectionInfo(String consumerGroup) throws InterruptedException, MQBrokerException, RemotingException, MQClientException {
    ConsumerConnection result = new ConsumerConnection();
    String topic = MixAll.getRetryTopic(consumerGroup);
    List<BrokerData> brokers = this.examineTopicRouteInfo(topic).getBrokerDatas();
    BrokerData brokerData = brokers.get(random.nextInt(brokers.size()));
    String addr = null;
    if (brokerData != null) {
        addr = brokerData.selectBrokerAddr();
        if (StringUtils.isNotBlank(addr)) {
            result = this.mqClientInstance.getMQClientAPIImpl().getConsumerConnectionList(addr, consumerGroup, timeoutMillis);
        }
    }
    if (result.getConnectionSet().isEmpty()) {
        log.warn("the consumer group not online. brokerAddr={}, group={}", addr, consumerGroup);
        throw new MQClientException(ResponseCode.CONSUMER_NOT_ONLINE, "Not found the consumer group connection");
    }
    return result;
}
Also used : BrokerData(org.apache.rocketmq.common.protocol.route.BrokerData) ConsumerConnection(org.apache.rocketmq.common.protocol.body.ConsumerConnection) MQClientException(org.apache.rocketmq.client.exception.MQClientException)

Aggregations

ConsumerConnection (org.apache.rocketmq.common.protocol.body.ConsumerConnection)36 Connection (org.apache.rocketmq.common.protocol.body.Connection)22 ConsumerRunningInfo (org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo)15 DefaultMQAdminExt (org.apache.rocketmq.tools.admin.DefaultMQAdminExt)14 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)13 SubscriptionData (org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData)12 HashMap (java.util.HashMap)10 Entry (java.util.Map.Entry)10 MQClientException (org.apache.rocketmq.client.exception.MQClientException)10 SubCommandException (org.apache.rocketmq.tools.command.SubCommandException)10 ConsumeStats (org.apache.rocketmq.common.admin.ConsumeStats)9 Field (java.lang.reflect.Field)8 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)8 TreeMap (java.util.TreeMap)8 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)8 MQClientAPIImpl (org.apache.rocketmq.client.impl.MQClientAPIImpl)8 MQClientInstance (org.apache.rocketmq.client.impl.factory.MQClientInstance)8 OffsetWrapper (org.apache.rocketmq.common.admin.OffsetWrapper)8 BrokerData (org.apache.rocketmq.common.protocol.route.BrokerData)8