Java源码示例:com.alibaba.rocketmq.common.protocol.body.Connection

示例1
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);
    }
}
 
示例2
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);
    }
}
 
示例3
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();
        // 低于3.1.8版本,不支持此功能
        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);
    }
}
 
示例4
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String group = commandLine.getOptionValue('g').trim();
        String topic = commandLine.getOptionValue('t').trim();

        ProducerConnection pc = defaultMQAdminExt.examineProducerConnectionInfo(group, topic);

        int i = 1;
        for (Connection conn : pc.getConnectionSet()) {
            System.out.printf("%04d  %-32s %-22s %-8s %s\n",//
                i++,//
                conn.getClientId(),//
                conn.getClientAddr(),//
                conn.getLanguage(),//
                MQVersion.getVersionDesc(conn.getVersion())//
                );
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
示例5
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String group = commandLine.getOptionValue('g').trim();
        String topic = commandLine.getOptionValue('t').trim();

        ProducerConnection pc = defaultMQAdminExt.examineProducerConnectionInfo(group, topic);

        int i = 1;
        for (Connection conn : pc.getConnectionSet()) {
            System.out.printf("%04d  %-32s %-22s %-8s %s%n",//
                    i++,//
                    conn.getClientId(),//
                    conn.getClientAddr(),//
                    conn.getLanguage(),//
                    MQVersion.getVersionDesc(conn.getVersion())//
            );
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
示例6
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String group = commandLine.getOptionValue('g').trim();
        String topic = commandLine.getOptionValue('t').trim();

        ProducerConnection pc = defaultMQAdminExt.examineProducerConnectionInfo(group, topic);

        int i = 1;
        for (Connection conn : pc.getConnectionSet()) {
            System.out.printf("%04d  %-32s %-22s %-8s %s\n", //
                i++, //
                conn.getClientId(), //
                conn.getClientAddr(), //
                conn.getLanguage(), //
                MQVersion.getVersionDesc(conn.getVersion())//
            );
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
示例7
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String group = commandLine.getOptionValue('g').trim();

        ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group);

        int i = 1;
        for (Connection conn : cc.getConnectionSet()) {
            System.out.printf("%03d  %-32s %-22s %-8s %s\n",//
                i++,//
                conn.getClientId(),//
                conn.getClientAddr(),//
                conn.getLanguage(),//
                MQVersion.getVersionDesc(conn.getVersion())//
                );
        }

        System.out.println("\nBelow is subscription:");
        Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator();
        i = 1;
        while (it.hasNext()) {
            Entry<String, SubscriptionData> entry = it.next();
            SubscriptionData sd = entry.getValue();
            System.out.printf("%03d  Topic: %-40s SubExpression: %s\n",//
                i++,//
                sd.getTopic(),//
                sd.getSubString()//
                );
        }

        System.out.println("");
        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) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}
 
示例8
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String group = commandLine.getOptionValue('g').trim();

        ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group);


        int i = 1;
        for (Connection conn : cc.getConnectionSet()) {
            System.out.printf("%03d  %-32s %-22s %-8s %s%n",//
                    i++,//
                    conn.getClientId(),//
                    conn.getClientAddr(),//
                    conn.getLanguage(),//
                    MQVersion.getVersionDesc(conn.getVersion())//
            );
        }


        System.out.println("\nBelow is subscription:");
        Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator();
        i = 1;
        while (it.hasNext()) {
            Entry<String, SubscriptionData> entry = it.next();
            SubscriptionData sd = entry.getValue();
            System.out.printf("%03d  Topic: %-40s SubExpression: %s%n",//
                    i++,//
                    sd.getTopic(),//
                    sd.getSubString()//
            );
        }


        System.out.println("");
        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) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
示例9
@Override
public void execute(CommandLine commandLine, Options options, RPCHook rpcHook) {
    DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);

    defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));

    try {
        defaultMQAdminExt.start();

        String group = commandLine.getOptionValue('g').trim();

        ConsumerConnection cc = defaultMQAdminExt.examineConsumerConnectionInfo(group);

        // 打印连接
        int i = 1;
        for (Connection conn : cc.getConnectionSet()) {
            System.out.printf("%03d  %-32s %-22s %-8s %s\n", //
                i++, //
                conn.getClientId(), //
                conn.getClientAddr(), //
                conn.getLanguage(), //
                MQVersion.getVersionDesc(conn.getVersion())//
            );
        }

        // 打印订阅关系
        System.out.println("\nBelow is subscription:");
        Iterator<Entry<String, SubscriptionData>> it = cc.getSubscriptionTable().entrySet().iterator();
        i = 1;
        while (it.hasNext()) {
            Entry<String, SubscriptionData> entry = it.next();
            SubscriptionData sd = entry.getValue();
            System.out.printf("%03d  Topic: %-40s SubExpression: %s\n", //
                i++, //
                sd.getTopic(), //
                sd.getSubString()//
            );
        }

        // 打印其他订阅参数
        System.out.println("");
        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) {
        e.printStackTrace();
    }
    finally {
        defaultMQAdminExt.shutdown();
    }
}