@Override
 public SubscriptionGroupConfig getGroupConfig(
     DefaultMQAdminExt defaultMQAdminExt, String groupName) {
   try {
     ConsumerConnection consumerConnection =
         defaultMQAdminExt.examineConsumerConnectionInfo(groupName);
     if (null != consumerConnection) {
       for (Connection connection : consumerConnection.getConnectionSet()) {
         String clientId = connection.getClientId();
         if (null != clientId && !clientId.isEmpty()) {
           ConsumerRunningInfo info =
               defaultMQAdminExt.getConsumerRunningInfo(groupName, clientId, true);
           if (null != info) {
             return null;
           }
         }
       }
     }
   } catch (Exception e) {
     System.out.println("try to get SubscriptionGroupConfig failed! group :" + groupName + e);
   }
   return null;
 }
Esempio n. 2
0
  private RemotingCommand getProducerConnectionList(
      ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetProducerConnectionListRequestHeader requestHeader =
        (GetProducerConnectionListRequestHeader)
            request.decodeCommandCustomHeader(GetProducerConnectionListRequestHeader.class);

    ConsumerConnection bodydata = new ConsumerConnection();
    HashMap<Channel, ClientChannelInfo> channelInfoHashMap =
        this.brokerController
            .getProducerManager()
            .getGroupChannelTable()
            .get(requestHeader.getProducerGroup());
    if (channelInfoHashMap != null) {
      Iterator<Map.Entry<Channel, ClientChannelInfo>> it = channelInfoHashMap.entrySet().iterator();
      while (it.hasNext()) {
        ClientChannelInfo info = it.next().getValue();
        Connection connection = new Connection();
        connection.setClientId(info.getClientId());
        connection.setLanguage(info.getLanguage());
        connection.setVersion(info.getVersion());
        connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));

        bodydata.getConnectionSet().add(connection);
      }

      byte[] body = bodydata.encode();
      response.setBody(body);
      response.setCode(ResponseCode.SUCCESS_VALUE);
      response.setRemark(null);
      return response;
    }

    response.setCode(ResponseCode.SYSTEM_ERROR_VALUE);
    response.setRemark("the producer group[" + requestHeader.getProducerGroup() + "] not exist");
    return response;
  }
Esempio n. 3
0
  private RemotingCommand getConsumerConnectionList(
      ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final GetConsumerConnectionListRequestHeader requestHeader =
        (GetConsumerConnectionListRequestHeader)
            request.decodeCommandCustomHeader(GetConsumerConnectionListRequestHeader.class);

    ConsumerGroupInfo consumerGroupInfo =
        this.brokerController
            .getConsumerManager()
            .getConsumerGroupInfo(requestHeader.getConsumerGroup());
    if (consumerGroupInfo != null) {
      ConsumerConnection bodydata = new ConsumerConnection();
      bodydata.setConsumeFromWhere(consumerGroupInfo.getConsumeFromWhere());
      bodydata.setConsumeType(consumerGroupInfo.getConsumeType());
      bodydata.setMessageModel(consumerGroupInfo.getMessageModel());
      bodydata.getSubscriptionTable().putAll(consumerGroupInfo.getSubscriptionTable());

      Iterator<Map.Entry<Channel, ClientChannelInfo>> it =
          consumerGroupInfo.getChannelInfoTable().entrySet().iterator();
      while (it.hasNext()) {
        ClientChannelInfo info = it.next().getValue();
        Connection connection = new Connection();
        connection.setClientId(info.getClientId());
        connection.setLanguage(info.getLanguage());
        connection.setVersion(info.getVersion());
        connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel()));

        bodydata.getConnectionSet().add(connection);
      }

      byte[] body = bodydata.encode();
      response.setBody(body);
      response.setCode(ResponseCode.SUCCESS_VALUE);
      response.setRemark(null);

      return response;
    }

    response.setCode(MQResponseCode.SUBSCRIPTION_GROUP_NOT_EXIST_VALUE);
    response.setRemark("the consumer group[" + requestHeader.getConsumerGroup() + "] not online");
    return response;
  }