use of org.apache.rocketmq.common.protocol.body.Connection in project rocketmq-externals by apache.
the class ConsumerServiceImpl method getClientConnection.
private Map<MessageQueue, String> getClientConnection(String groupName) {
Map<MessageQueue, String> results = Maps.newHashMap();
try {
ConsumerConnection consumerConnection = mqAdminExt.examineConsumerConnectionInfo(groupName);
for (Connection connection : consumerConnection.getConnectionSet()) {
String clinetId = connection.getClientId();
ConsumerRunningInfo consumerRunningInfo = mqAdminExt.getConsumerRunningInfo(groupName, clinetId, false);
for (MessageQueue messageQueue : consumerRunningInfo.getMqTable().keySet()) {
// results.put(messageQueue, clinetId + " " + connection.getClientAddr());
results.put(messageQueue, clinetId);
}
}
} catch (Exception err) {
logger.error("op=getClientConnection_error", err);
}
return results;
}
use of org.apache.rocketmq.common.protocol.body.Connection in project rocketmq-externals by apache.
the class ConsumerServiceImplTest method getConsumerConnection.
@Test
public void getConsumerConnection() throws Exception {
ConsumerConnection consumerConnection = new RetryTempLate<ConsumerConnection>() {
@Override
protected ConsumerConnection process() throws Exception {
return consumerService.getConsumerConnection(TEST_CONSUMER_GROUP);
}
}.execute(10, 2000);
Assert.assertNotNull(consumerConnection);
Assert.assertTrue(CollectionUtils.isNotEmpty(consumerConnection.getConnectionSet()));
Assert.assertTrue(Lists.transform(Lists.newArrayList(consumerConnection.getConnectionSet()), new Function<Connection, String>() {
@Override
public String apply(Connection input) {
return input.getClientAddr().split(":")[0];
}
}).contains(TestConstant.BROKER_IP));
}
use of org.apache.rocketmq.common.protocol.body.Connection in project rocketmq-externals by apache.
the class ProducerServiceImplTest method getProducerConnection.
@Test
public void getProducerConnection() throws Exception {
ProducerConnection producerConnection = new RetryTempLate<ProducerConnection>() {
@Override
protected ProducerConnection process() throws Exception {
return producerService.getProducerConnection(TEST_PRODUCER_GROUP, TEST_CONSOLE_TOPIC);
}
}.execute(10, 1000);
Assert.assertNotNull(producerConnection);
Assert.assertTrue(Lists.transform(Lists.newArrayList(producerConnection.getConnectionSet()), new Function<Connection, String>() {
@Override
public String apply(Connection input) {
return input.getClientAddr().split(":")[0];
}
}).contains(TestConstant.LOCAL_HOST));
}
Aggregations