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()); connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel())); bodydata.getConnectionSet().add(connection); byte[] body = bodydata.encode(); response.setBody(body); response.setCode(ResponseCode.SUCCESS);
groupConsumeInfo.setCount(cc.getConnectionSet().size()); groupConsumeInfo.setMessageModel(cc.getMessageModel()); groupConsumeInfo.setConsumeType(cc.getConsumeType()); groupConsumeInfo.setVersion(cc.computeMinVersion());
public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return ConsumerConnection.decode(response.getBody(), ConsumerConnection.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
@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; }
for (Connection conn : cc.getConnectionSet()) { System.out.printf("%03d %-32s %-22s %-8s %s%n", i++, Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); i = 1; while (it.hasNext()) { System.out.printf("ConsumeType: %s%n", cc.getConsumeType()); System.out.printf("MessageModel: %s%n", cc.getMessageModel()); System.out.printf("ConsumeFromWhere: %s%n", cc.getConsumeFromWhere()); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
private Map<MessageQueue, String> getMessageQueueAllocationResult(DefaultMQAdminExt defaultMQAdminExt, String groupName) { Map<MessageQueue, String> results = new HashMap<>(); try { ConsumerConnection consumerConnection = defaultMQAdminExt.examineConsumerConnectionInfo(groupName); for (Connection connection : consumerConnection.getConnectionSet()) { String clientId = connection.getClientId(); ConsumerRunningInfo consumerRunningInfo = defaultMQAdminExt.getConsumerRunningInfo(groupName, clientId, false); for (MessageQueue messageQueue : consumerRunningInfo.getMqTable().keySet()) { results.put(messageQueue, clientId.split("@")[0]); } } } catch (Exception ignore) { } return results; }
switch (cc.getConsumeType()) { case CONSUME_ACTIVELY: mt.setTrackType(TrackType.PULL); Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, SubscriptionData> next = it.next();
for (Connection conn : cc.getConnectionSet()) { System.out.printf("%03d %-32s %-22s %-8s %s%n", i++, Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); i = 1; while (it.hasNext()) { System.out.printf("ConsumeType: %s%n", cc.getConsumeType()); System.out.printf("MessageModel: %s%n", cc.getMessageModel()); System.out.printf("ConsumeFromWhere: %s%n", cc.getConsumeFromWhere()); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
public void reportConsumerRunningInfo(final String consumerGroup) throws InterruptedException, MQBrokerException, RemotingException, MQClientException { ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(consumerGroup); TreeMap<String, ConsumerRunningInfo> infoMap = new TreeMap<String, ConsumerRunningInfo>(); for (Connection c : cc.getConnectionSet()) { String clientId = c.getClientId(); if (c.getVersion() < MQVersion.Version.V3_1_8_SNAPSHOT.ordinal()) { continue; } try { ConsumerRunningInfo info = defaultMQAdminExt.getConsumerRunningInfo(consumerGroup, clientId, false); infoMap.put(clientId, info); } catch (Exception e) { } } if (!infoMap.isEmpty()) { this.monitorListener.reportConsumerRunningInfo(infoMap); } }
@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; }
switch (cc.getConsumeType()) { case CONSUME_ACTIVELY: mt.setTrackType(TrackType.PULL); Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, SubscriptionData> next = it.next();
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()); connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel())); bodydata.getConnectionSet().add(connection); byte[] body = bodydata.encode(); response.setBody(body); response.setCode(ResponseCode.SUCCESS);
for (Connection conn : cc.getConnectionSet()) { System.out.printf("%03d %-32s %-22s %-8s %s%n", i++, Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); i = 1; while (it.hasNext()) { System.out.printf("ConsumeType: %s%n", cc.getConsumeType()); System.out.printf("MessageModel: %s%n", cc.getMessageModel()); System.out.printf("ConsumeFromWhere: %s%n", cc.getConsumeFromWhere()); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e);
groupConsumeInfo.setCount(cc.getConnectionSet().size()); groupConsumeInfo.setMessageModel(cc.getMessageModel()); groupConsumeInfo.setConsumeType(cc.getConsumeType()); groupConsumeInfo.setVersion(cc.computeMinVersion());
long now = System.currentTimeMillis(); final TreeMap<String/* clientId */, ConsumerRunningInfo> criTable = new TreeMap<String, ConsumerRunningInfo>(); for (Connection conn : cc.getConnectionSet()) { try { ConsumerRunningInfo consumerRunningInfo =
@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; }
switch (cc.getConsumeType()) { case CONSUME_ACTIVELY: mt.setTrackType(TrackType.PULL); Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator(); while (it.hasNext()) { Entry<String, SubscriptionData> next = it.next();
public ConsumerConnection getConsumerConnectionList(final String addr, final String consumerGroup, final long timeoutMillis) throws RemotingConnectException, RemotingSendRequestException, RemotingTimeoutException, InterruptedException, MQBrokerException { GetConsumerConnectionListRequestHeader requestHeader = new GetConsumerConnectionListRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_CONNECTION_LIST, requestHeader); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); switch (response.getCode()) { case ResponseCode.SUCCESS: { return ConsumerConnection.decode(response.getBody(), ConsumerConnection.class); } default: break; } throw new MQBrokerException(response.getCode(), response.getRemark()); }
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()); connection.setClientAddr(RemotingHelper.parseChannelRemoteAddr(info.getChannel())); bodydata.getConnectionSet().add(connection); byte[] body = bodydata.encode(); response.setBody(body); response.setCode(ResponseCode.SUCCESS);
groupConsumeInfo.setCount(cc.getConnectionSet().size()); groupConsumeInfo.setMessageModel(cc.getMessageModel()); groupConsumeInfo.setConsumeType(cc.getConsumeType()); groupConsumeInfo.setVersion(cc.computeMinVersion());