com.alibaba.rocketmq.common.protocol.body.ProducerConnection Java Examples

The following examples show how to use com.alibaba.rocketmq.common.protocol.body.ProducerConnection. 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: ConnectionService.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@CmdTrace(cmdClazz = ProducerConnectionSubCommand.class)
public ProducerConnection getProducerConnection(String group, String topicName) throws Throwable {
    Throwable t = null;
    DefaultMQAdminExt defaultMQAdminExt = getDefaultMQAdminExt();
    try {
        defaultMQAdminExt.start();
        ProducerConnection pc = defaultMQAdminExt.examineProducerConnectionInfo(group, topicName);
        return pc;
    }
    catch (Throwable e) {
        logger.error(e.getMessage(), e);
        t = e;
    }
    finally {
        shutdownDefaultMQAdminExt(defaultMQAdminExt);
    }
    throw t;
}
 
Example #2
Source File: ConnectionAction.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/producerConnection.do", method = { RequestMethod.GET, RequestMethod.POST })
public String producerConnection(ModelMap map, HttpServletRequest request,
        @RequestParam(required = false) String producerGroup, @RequestParam(required = false) String topic) {
    Collection<Option> options = connectionService.getOptionsForGetProducerConnection();
    putPublicAttribute(map, "producerConnection", options, request);
    try {
        if (request.getMethod().equals(GET)) {

        }
        else if (request.getMethod().equals(POST)) {
            checkOptions(options);
            ProducerConnection pc = connectionService.getProducerConnection(producerGroup, topic);
            map.put("pc", pc);
        }
        else {
            throwUnknowRequestMethodException(request);
        }
    }
    catch (Throwable e) {
        putAlertMsg(e, map);
    }
    return TEMPLATE;
}
 
Example #3
Source File: ProducerConnectionSubCommand.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example #4
Source File: ProducerServiceImpl.java    From rocket-console with Apache License 2.0 5 votes vote down vote up
@Override
public ProducerConnection getProducerConnection(String producerGroup, String topic) {
    try {
        return mqAdminExt.examineProducerConnectionInfo(producerGroup, topic);
    } catch (RemotingException | MQClientException | MQBrokerException | InterruptedException e) {
        throw Throwables.propagate(e);
    }
}
 
Example #5
Source File: ProducerConnectionSubCommand.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example #6
Source File: ProducerConnectionSubCommand.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example #7
Source File: MQAdminExtImpl.java    From rocket-console with Apache License 2.0 4 votes vote down vote up
@Override
public ProducerConnection examineProducerConnectionInfo(String producerGroup, String topic)
        throws RemotingException, MQClientException, InterruptedException, MQBrokerException {
    return MQAdminInstance.threadLocalMQAdminExt().examineProducerConnectionInfo(producerGroup, topic);
}
 
Example #8
Source File: ProducerService.java    From rocket-console with Apache License 2.0 votes vote down vote up
ProducerConnection getProducerConnection(String producerGroup, String topic);