org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo Java Examples
The following examples show how to use
org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MonitorService.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
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); } }
Example #2
Source File: MonitorService.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
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); } }
Example #3
Source File: ConsumerProgressSubCommand.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
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; }
Example #4
Source File: MonitorService.java From rocketmq with Apache License 2.0 | 6 votes |
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); } }
Example #5
Source File: DefaultMQAdminExtImpl.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Override public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack) throws RemotingException, MQClientException, InterruptedException { String topic = MixAll.RETRY_GROUP_TOPIC_PREFIX + consumerGroup; TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic); List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas(); if (brokerDatas != null) { for (BrokerData brokerData : brokerDatas) { String addr = brokerData.selectBrokerAddr(); if (addr != null) { return this.mqClientInstance.getMQClientAPIImpl().getConsumerRunningInfo(addr, consumerGroup, clientId, jstack, timeoutMillis * 3); } } } return null; }
Example #6
Source File: ClientRemotingProcessor.java From DDMQ with Apache License 2.0 | 6 votes |
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class); ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup()); if (null != consumerRunningInfo) { if (requestHeader.isJstackEnable()) { Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); String jstack = UtilAll.jstack(map); consumerRunningInfo.setJstack(jstack); } response.setCode(ResponseCode.SUCCESS); response.setBody(consumerRunningInfo.encode()); } else { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup())); } return response; }
Example #7
Source File: ClientRemotingProcessor.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class); ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup()); if (null != consumerRunningInfo) { if (requestHeader.isJstackEnable()) { Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); String jstack = UtilAll.jstack(map); consumerRunningInfo.setJstack(jstack); } response.setCode(ResponseCode.SUCCESS); response.setBody(consumerRunningInfo.encode()); } else { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup())); } return response; }
Example #8
Source File: ConsumerProgressSubCommand.java From rocketmq with Apache License 2.0 | 6 votes |
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; }
Example #9
Source File: ClientRemotingProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class); ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup()); if (null != consumerRunningInfo) { if (requestHeader.isJstackEnable()) { Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); String jstack = UtilAll.jstack(map); consumerRunningInfo.setJstack(jstack); } response.setCode(ResponseCode.SUCCESS); response.setBody(consumerRunningInfo.encode()); } else { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup())); } return response; }
Example #10
Source File: ClientRemotingProcessor.java From rocketmq-read with Apache License 2.0 | 6 votes |
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader) request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class); ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup()); if (null != consumerRunningInfo) { if (requestHeader.isJstackEnable()) { Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); String jstack = UtilAll.jstack(map); consumerRunningInfo.setJstack(jstack); } response.setCode(ResponseCode.SUCCESS); response.setBody(consumerRunningInfo.encode()); } else { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup())); } return response; }
Example #11
Source File: DefaultMQAdminExtImpl.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public ConsumerRunningInfo getConsumerRunningInfo(String consumerGroup, String clientId, boolean jstack) throws RemotingException, MQClientException, InterruptedException { String topic = MixAll.RETRY_GROUP_TOPIC_PREFIX + consumerGroup; TopicRouteData topicRouteData = this.examineTopicRouteInfo(topic); List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas(); if (brokerDatas != null) { for (BrokerData brokerData : brokerDatas) { String addr = brokerData.selectBrokerAddr(); if (addr != null) { return this.mqClientInstance.getMQClientAPIImpl().getConsumerRunningInfo(addr, consumerGroup, clientId, jstack, timeoutMillis * 3); } } } return null; }
Example #12
Source File: ConsumerProgressSubCommand.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
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; }
Example #13
Source File: ClientRemotingProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
private RemotingCommand getConsumerRunningInfo(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException { final RemotingCommand response = RemotingCommand.createResponseCommand(null); final GetConsumerRunningInfoRequestHeader requestHeader = (GetConsumerRunningInfoRequestHeader)request.decodeCommandCustomHeader(GetConsumerRunningInfoRequestHeader.class); ConsumerRunningInfo consumerRunningInfo = this.mqClientFactory.consumerRunningInfo(requestHeader.getConsumerGroup()); if (null != consumerRunningInfo) { if (requestHeader.isJstackEnable()) { Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); String jstack = UtilAll.jstack(map); consumerRunningInfo.setJstack(jstack); } response.setCode(ResponseCode.SUCCESS); response.setBody(consumerRunningInfo.encode()); } else { response.setCode(ResponseCode.SYSTEM_ERROR); response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup())); } return response; }
Example #14
Source File: MonitorService.java From DDMQ with Apache License 2.0 | 6 votes |
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); } }
Example #15
Source File: ConsumerProgressSubCommand.java From rocketmq-read with Apache License 2.0 | 6 votes |
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; }
Example #16
Source File: MonitorService.java From rocketmq with Apache License 2.0 | 6 votes |
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); } }
Example #17
Source File: ConsumerStatusSubCommand.java From DDMQ with Apache License 2.0 | 6 votes |
private void printRebalanceResult(TreeMap<String, ConsumerRunningInfo> criTable) { if (criTable == null || criTable.isEmpty()) { System.out.printf("Empty Result: criTable is empty.\n"); return; } Map<MessageQueue, String> rbResult = new TreeMap<MessageQueue, String>(); for (String cid : criTable.keySet()) { for (MessageQueue messageQueue : criTable.get(cid).getMqTable().keySet()) { rbResult.put(messageQueue, cid); } } String format = "%30s|%20s|%10s| %s\n"; System.out.printf("--------------------------------------------------------------------------------------------------\n"); System.out.printf(format, "Topic","Broker Name", "QueueId", "ConsumerClientId"); System.out.printf("--------------------------------------------------------------------------------------------------\n"); for (Entry<MessageQueue, String> entry : rbResult.entrySet()) { System.out.printf(format, entry.getKey().getTopic(), entry.getKey().getBrokerName(), entry.getKey().getQueueId(), entry.getValue()); } }
Example #18
Source File: ConsumerProgressSubCommand.java From DDMQ with Apache License 2.0 | 6 votes |
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; }
Example #19
Source File: ConsumerProgressSubCommand.java From DDMQ with Apache License 2.0 | 6 votes |
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; }
Example #20
Source File: ConsumerStatusSubCommand.java From DDMQ with Apache License 2.0 | 6 votes |
private void printRebalanceResult(TreeMap<String, ConsumerRunningInfo> criTable) { if (criTable == null || criTable.isEmpty()) { System.out.printf("Empty Result: criTable is empty.\n"); return; } Map<MessageQueue, String> rbResult = new TreeMap<MessageQueue, String>(); for (String cid : criTable.keySet()) { for (MessageQueue messageQueue : criTable.get(cid).getMqTable().keySet()) { rbResult.put(messageQueue, cid); } } String format = "%30s|%20s|%10s| %s\n"; System.out.printf("--------------------------------------------------------------------------------------------------\n"); System.out.printf(format, "Topic","Broker Name", "QueueId", "ConsumerClientId"); System.out.printf("--------------------------------------------------------------------------------------------------\n"); for (Entry<MessageQueue, String> entry : rbResult.entrySet()) { System.out.printf(format, entry.getKey().getTopic(), entry.getKey().getBrokerName(), entry.getKey().getQueueId(), entry.getValue()); } }
Example #21
Source File: MQClientAPIImpl.java From rocketmq-read with Apache License 2.0 | 5 votes |
public ConsumerRunningInfo getConsumerRunningInfo(final String addr, String consumerGroup, String clientId, boolean jstack, final long timeoutMillis) throws RemotingException, MQClientException, InterruptedException { GetConsumerRunningInfoRequestHeader requestHeader = new GetConsumerRunningInfoRequestHeader(); requestHeader.setConsumerGroup(consumerGroup); requestHeader.setClientId(clientId); requestHeader.setJstackEnable(jstack); RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_CONSUMER_RUNNING_INFO, requestHeader); String acturallyAddr = getActurallyBrokerAddr(addr); RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), acturallyAddr), request, timeoutMillis); assert response != null; switch (response.getCode()) { case ResponseCode.SUCCESS: { byte[] body = response.getBody(); if (body != null) { ConsumerRunningInfo info = ConsumerRunningInfo.decode(body, ConsumerRunningInfo.class); return info; } } default: break; } throw new MQClientException(response.getCode(), response.getRemark()); }
Example #22
Source File: DefaultMQPushConsumerImpl.java From DDMQ with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #23
Source File: DefaultMQPushConsumerImpl.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 获取消费者的运行时信息 * @return ; */ @Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #24
Source File: DefaultMQPullConsumerImpl.java From rocketmq_trans_message with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPullConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); info.getSubscriptionSet().addAll(this.subscriptions()); return info; }
Example #25
Source File: AbstractCarreraRocketMqConsumer.java From DDMQ with Apache License 2.0 | 5 votes |
private Set<String> fetchSubscribeQid(String topic) throws MQClientException { Optional<DefaultMQPushConsumer> consumer = Optional.ofNullable(rmqConsumer); if (!consumer.isPresent()) { return Collections.emptySet(); } Set<MessageQueue> mqSet = consumer.map(DefaultMQPushConsumer::getDefaultMQPushConsumerImpl) .map(DefaultMQPushConsumerImpl::consumerRunningInfo) .map(ConsumerRunningInfo::getMqTable) .map(Map::keySet) .orElse(Collections.emptySet()); return mqSet.stream().filter(messageQueue -> messageQueue.getTopic().equals(topic)) .map(messageQueue -> QidUtils.rmqMakeQid(rocketmqConfiguration.getClusterName(), messageQueue.getBrokerName(), messageQueue.getQueueId())) .collect(Collectors.toSet()); }
Example #26
Source File: DefaultMQPushConsumerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }
Example #27
Source File: DefaultMonitorListenerTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #28
Source File: DefaultMQPullConsumerImpl.java From DDMQ with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPullConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); info.getSubscriptionSet().addAll(this.subscriptions()); return info; }
Example #29
Source File: DefaultMonitorListenerTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testReportConsumerRunningInfo() { TreeMap<String, ConsumerRunningInfo> criTable = new TreeMap<>(); ConsumerRunningInfo consumerRunningInfo = new ConsumerRunningInfo(); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setStatusTable(new TreeMap<String, ConsumeStatus>()); consumerRunningInfo.setSubscriptionSet(new TreeSet<SubscriptionData>()); consumerRunningInfo.setMqTable(new TreeMap<MessageQueue, ProcessQueueInfo>()); consumerRunningInfo.setProperties(new Properties()); criTable.put("test", consumerRunningInfo); defaultMonitorListener.reportConsumerRunningInfo(criTable); }
Example #30
Source File: DefaultMQPushConsumerImpl.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Override public ConsumerRunningInfo consumerRunningInfo() { ConsumerRunningInfo info = new ConsumerRunningInfo(); Properties prop = MixAll.object2Properties(this.defaultMQPushConsumer); prop.put(ConsumerRunningInfo.PROP_CONSUME_ORDERLY, String.valueOf(this.consumeOrderly)); prop.put(ConsumerRunningInfo.PROP_THREADPOOL_CORE_SIZE, String.valueOf(this.consumeMessageService.getCorePoolSize())); prop.put(ConsumerRunningInfo.PROP_CONSUMER_START_TIMESTAMP, String.valueOf(this.consumerStartTimestamp)); info.setProperties(prop); Set<SubscriptionData> subSet = this.subscriptions(); info.getSubscriptionSet().addAll(subSet); Iterator<Entry<MessageQueue, ProcessQueue>> it = this.rebalanceImpl.getProcessQueueTable().entrySet().iterator(); while (it.hasNext()) { Entry<MessageQueue, ProcessQueue> next = it.next(); MessageQueue mq = next.getKey(); ProcessQueue pq = next.getValue(); ProcessQueueInfo pqinfo = new ProcessQueueInfo(); pqinfo.setCommitOffset(this.offsetStore.readOffset(mq, ReadOffsetType.MEMORY_FIRST_THEN_STORE)); pq.fillProcessQueueInfo(pqinfo); info.getMqTable().put(mq, pqinfo); } for (SubscriptionData sd : subSet) { ConsumeStatus consumeStatus = this.mQClientFactory.getConsumerStatsManager().consumeStatus(this.groupName(), sd.getTopic()); info.getStatusTable().put(sd.getTopic(), consumeStatus); } return info; }