org.apache.rocketmq.common.protocol.body.QueryConsumeQueueResponseBody Java Examples

The following examples show how to use org.apache.rocketmq.common.protocol.body.QueryConsumeQueueResponseBody. 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: MQClientAPIImpl.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
public QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr, final String topic,
    final int queueId,
    final long index, final int count, final String consumerGroup,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {

    QueryConsumeQueueRequestHeader requestHeader = new QueryConsumeQueueRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    requestHeader.setIndex(index);
    requestHeader.setCount(count);
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_QUEUE, requestHeader);

    String acturallyAddr = getActurallyBrokerAddr(brokerAddr);
    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), acturallyAddr), request, timeoutMillis);

    assert response != null;

    if (ResponseCode.SUCCESS == response.getCode()) {
        return QueryConsumeQueueResponseBody.decode(response.getBody(), QueryConsumeQueueResponseBody.class);
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
Example #2
Source File: MQClientAPIImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
public QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr, final String topic, final int queueId,
                                               final long index, final int count, final String consumerGroup,
                                               final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {

    QueryConsumeQueueRequestHeader requestHeader = new QueryConsumeQueueRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    requestHeader.setIndex(index);
    requestHeader.setCount(count);
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_QUEUE, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);

    assert response != null;

    if (ResponseCode.SUCCESS == response.getCode()) {
        return QueryConsumeQueueResponseBody.decode(response.getBody(), QueryConsumeQueueResponseBody.class);
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
Example #3
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr, final String topic,
    final int queueId,
    final long index, final int count, final String consumerGroup,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {

    QueryConsumeQueueRequestHeader requestHeader = new QueryConsumeQueueRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    requestHeader.setIndex(index);
    requestHeader.setCount(count);
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_QUEUE, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);

    assert response != null;

    if (ResponseCode.SUCCESS == response.getCode()) {
        return QueryConsumeQueueResponseBody.decode(response.getBody(), QueryConsumeQueueResponseBody.class);
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
Example #4
Source File: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr, final String topic,
    final int queueId,
    final long index, final int count, final String consumerGroup,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {

    QueryConsumeQueueRequestHeader requestHeader = new QueryConsumeQueueRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    requestHeader.setIndex(index);
    requestHeader.setCount(count);
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_QUEUE, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);

    assert response != null;

    if (ResponseCode.SUCCESS == response.getCode()) {
        return QueryConsumeQueueResponseBody.decode(response.getBody(), QueryConsumeQueueResponseBody.class);
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
Example #5
Source File: MQClientAPIImpl.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
public QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr, final String topic,
    final int queueId,
    final long index, final int count, final String consumerGroup,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {

    QueryConsumeQueueRequestHeader requestHeader = new QueryConsumeQueueRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    requestHeader.setIndex(index);
    requestHeader.setCount(count);
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_QUEUE, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);

    assert response != null;

    if (ResponseCode.SUCCESS == response.getCode()) {
        return QueryConsumeQueueResponseBody.decode(response.getBody(), QueryConsumeQueueResponseBody.class);
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
Example #6
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr, final String topic,
    final int queueId,
    final long index, final int count, final String consumerGroup,
    final long timeoutMillis) throws InterruptedException,
    RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {

    QueryConsumeQueueRequestHeader requestHeader = new QueryConsumeQueueRequestHeader();
    requestHeader.setTopic(topic);
    requestHeader.setQueueId(queueId);
    requestHeader.setIndex(index);
    requestHeader.setCount(count);
    requestHeader.setConsumerGroup(consumerGroup);

    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.QUERY_CONSUME_QUEUE, requestHeader);

    RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), brokerAddr), request, timeoutMillis);

    assert response != null;

    if (ResponseCode.SUCCESS == response.getCode()) {
        return QueryConsumeQueueResponseBody.decode(response.getBody(), QueryConsumeQueueResponseBody.class);
    }

    throw new MQClientException(response.getCode(), response.getRemark());
}
 
Example #7
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
    );
}
 
Example #8
Source File: DefaultMQAdminExt.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.defaultMQAdminExtImpl.queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup
    );
}
 
Example #9
Source File: DefaultMQAdminExtImpl.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
    );
}
 
Example #10
Source File: DefaultMQAdminExt.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.defaultMQAdminExtImpl.queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup
    );
}
 
Example #11
Source File: DefaultMQAdminExt.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.defaultMQAdminExtImpl.queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup
    );
}
 
Example #12
Source File: DefaultMQAdminExtImpl.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
    );
}
 
Example #13
Source File: DefaultMQAdminExtImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index, int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
    );
}
 
Example #14
Source File: DefaultMQAdminExt.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index, int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.defaultMQAdminExtImpl.queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup
    );
}
 
Example #15
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
    );
}
 
Example #16
Source File: DefaultMQAdminExt.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.defaultMQAdminExtImpl.queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup
    );
}
 
Example #17
Source File: DefaultMQAdminExtImpl.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.mqClientInstance.getMQClientAPIImpl().queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup, timeoutMillis
    );
}
 
Example #18
Source File: DefaultMQAdminExt.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic, int queueId, long index,
    int count, String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return this.defaultMQAdminExtImpl.queryConsumeQueue(
        brokerAddr, topic, queueId, index, count, consumerGroup
    );
}
 
Example #19
Source File: QueryConsumeQueueCommand.java    From rocketmq with Apache License 2.0 4 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 topic = commandLine.getOptionValue("t").trim();
        int queueId = Integer.valueOf(commandLine.getOptionValue("q").trim());
        long index = Long.valueOf(commandLine.getOptionValue("i").trim());
        int count = Integer.valueOf(commandLine.getOptionValue("c", "10").trim());
        String broker = null;
        if (commandLine.hasOption("b")) {
            broker = commandLine.getOptionValue("b").trim();
        }
        String consumerGroup = null;
        if (commandLine.hasOption("g")) {
            consumerGroup = commandLine.getOptionValue("g").trim();
        }

        if (broker == null || broker == "") {
            TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);

            if (topicRouteData == null || topicRouteData.getBrokerDatas() == null
                || topicRouteData.getBrokerDatas().isEmpty()) {
                throw new Exception("No topic route data!");
            }

            broker = topicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(0L);
        }

        QueryConsumeQueueResponseBody queryConsumeQueueResponseBody = defaultMQAdminExt.queryConsumeQueue(
            broker, topic, queueId, index, count, consumerGroup
        );

        if (queryConsumeQueueResponseBody.getSubscriptionData() != null) {
            System.out.printf("Subscription data: \n%s\n", JSON.toJSONString(queryConsumeQueueResponseBody.getSubscriptionData(), true));
            System.out.print("======================================\n");
        }

        if (queryConsumeQueueResponseBody.getFilterData() != null) {
            System.out.printf("Filter data: \n%s\n", queryConsumeQueueResponseBody.getFilterData());
            System.out.print("======================================\n");
        }

        System.out.printf("Queue data: \nmax: %d, min: %d\n", queryConsumeQueueResponseBody.getMaxQueueIndex(),
            queryConsumeQueueResponseBody.getMinQueueIndex());
        System.out.print("======================================\n");

        if (queryConsumeQueueResponseBody.getQueueData() != null) {

            long i = index;
            for (ConsumeQueueData queueData : queryConsumeQueueResponseBody.getQueueData()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("idx: " + i + "\n");

                stringBuilder.append(queueData.toString() + "\n");

                stringBuilder.append("======================================\n");

                System.out.print(stringBuilder.toString());
                i++;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #20
Source File: QueryConsumeQueueCommand.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 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 topic = commandLine.getOptionValue("t").trim();
        int queueId = Integer.valueOf(commandLine.getOptionValue("q").trim());
        long index = Long.valueOf(commandLine.getOptionValue("i").trim());
        int count = Integer.valueOf(commandLine.getOptionValue("c", "10").trim());
        String broker = null;
        if (commandLine.hasOption("b")) {
            broker = commandLine.getOptionValue("b").trim();
        }
        String consumerGroup = null;
        if (commandLine.hasOption("g")) {
            consumerGroup = commandLine.getOptionValue("g").trim();
        }

        if (broker == null || broker == "") {
            TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);

            if (topicRouteData == null || topicRouteData.getBrokerDatas() == null
                || topicRouteData.getBrokerDatas().isEmpty()) {
                throw new Exception("No topic route data!");
            }

            broker = topicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(0L);
        }

        QueryConsumeQueueResponseBody queryConsumeQueueResponseBody = defaultMQAdminExt.queryConsumeQueue(
            broker, topic, queueId, index, count, consumerGroup
        );

        if (queryConsumeQueueResponseBody.getSubscriptionData() != null) {
            System.out.printf("Subscription data: \n%s\n", JSON.toJSONString(queryConsumeQueueResponseBody.getSubscriptionData(), true));
            System.out.print("======================================\n");
        }

        if (queryConsumeQueueResponseBody.getFilterData() != null) {
            System.out.printf("Filter data: \n%s\n", queryConsumeQueueResponseBody.getFilterData());
            System.out.print("======================================\n");
        }

        System.out.printf("Queue data: \nmax: %d, min: %d\n", queryConsumeQueueResponseBody.getMaxQueueIndex(),
            queryConsumeQueueResponseBody.getMinQueueIndex());
        System.out.print("======================================\n");

        if (queryConsumeQueueResponseBody.getQueueData() != null) {

            long i = index;
            for (ConsumeQueueData queueData : queryConsumeQueueResponseBody.getQueueData()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("idx: " + i + "\n");

                stringBuilder.append(queueData.toString() + "\n");

                stringBuilder.append("======================================\n");

                System.out.print(stringBuilder.toString());
                i++;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #21
Source File: QueryConsumeQueueCommand.java    From DDMQ with Apache License 2.0 4 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 topic = commandLine.getOptionValue("t").trim();
        int queueId = Integer.valueOf(commandLine.getOptionValue("q").trim());
        long index = Long.valueOf(commandLine.getOptionValue("i").trim());
        int count = Integer.valueOf(commandLine.getOptionValue("c", "10").trim());
        String broker = null;
        if (commandLine.hasOption("b")) {
            broker = commandLine.getOptionValue("b").trim();
        }
        String consumerGroup = null;
        if (commandLine.hasOption("g")) {
            consumerGroup = commandLine.getOptionValue("g").trim();
        }

        if (broker == null || broker == "") {
            TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);

            if (topicRouteData == null || topicRouteData.getBrokerDatas() == null
                || topicRouteData.getBrokerDatas().isEmpty()) {
                throw new Exception("No topic route data!");
            }

            broker = topicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(0L);
        }

        QueryConsumeQueueResponseBody queryConsumeQueueResponseBody = defaultMQAdminExt.queryConsumeQueue(
            broker, topic, queueId, index, count, consumerGroup
        );

        if (queryConsumeQueueResponseBody.getSubscriptionData() != null) {
            System.out.printf("Subscription data: \n%s\n", JSON.toJSONString(queryConsumeQueueResponseBody.getSubscriptionData(), true));
            System.out.print("======================================\n");
        }

        if (queryConsumeQueueResponseBody.getFilterData() != null) {
            System.out.printf("Filter data: \n%s\n", queryConsumeQueueResponseBody.getFilterData());
            System.out.print("======================================\n");
        }

        System.out.printf("Queue data: \nmax: %d, min: %d\n", queryConsumeQueueResponseBody.getMaxQueueIndex(),
            queryConsumeQueueResponseBody.getMinQueueIndex());
        System.out.print("======================================\n");

        if (queryConsumeQueueResponseBody.getQueueData() != null) {

            long i = index;
            for (ConsumeQueueData queueData : queryConsumeQueueResponseBody.getQueueData()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("idx: " + i + "\n");

                stringBuilder.append(queueData.toString() + "\n");

                stringBuilder.append("======================================\n");

                System.out.print(stringBuilder.toString());
                i++;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #22
Source File: MQAdminExtImpl.java    From rocketmq-exporter with Apache License 2.0 4 votes vote down vote up
@Override
public QueryConsumeQueueResponseBody queryConsumeQueue(String brokerAddr, String topic,
                                                       int queueId, long index, int count,
                                                       String consumerGroup) throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException {
    return null;
}
 
Example #23
Source File: QueryConsumeQueueCommand.java    From rocketmq-read with Apache License 2.0 4 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 topic = commandLine.getOptionValue("t").trim();
        int queueId = Integer.valueOf(commandLine.getOptionValue("q").trim());
        long index = Long.valueOf(commandLine.getOptionValue("i").trim());
        int count = Integer.valueOf(commandLine.getOptionValue("c", "10").trim());
        String broker = null;
        if (commandLine.hasOption("b")) {
            broker = commandLine.getOptionValue("b").trim();
        }
        String consumerGroup = null;
        if (commandLine.hasOption("g")) {
            consumerGroup = commandLine.getOptionValue("g").trim();
        }

        if (broker == null || broker == "") {
            TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);

            if (topicRouteData == null || topicRouteData.getBrokerDatas() == null
                || topicRouteData.getBrokerDatas().isEmpty()) {
                throw new Exception("No topic route data!");
            }

            broker = topicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(0L);
        }

        QueryConsumeQueueResponseBody queryConsumeQueueResponseBody = defaultMQAdminExt.queryConsumeQueue(
            broker, topic, queueId, index, count, consumerGroup
        );

        if (queryConsumeQueueResponseBody.getSubscriptionData() != null) {
            System.out.printf("Subscription data: \n%s\n", JSON.toJSONString(queryConsumeQueueResponseBody.getSubscriptionData(), true));
            System.out.print("======================================\n");
        }

        if (queryConsumeQueueResponseBody.getFilterData() != null) {
            System.out.printf("Filter data: \n%s\n", queryConsumeQueueResponseBody.getFilterData());
            System.out.print("======================================\n");
        }

        System.out.printf("Queue data: \nmax: %d, min: %d\n", queryConsumeQueueResponseBody.getMaxQueueIndex(),
            queryConsumeQueueResponseBody.getMinQueueIndex());
        System.out.print("======================================\n");

        if (queryConsumeQueueResponseBody.getQueueData() != null) {

            long i = index;
            for (ConsumeQueueData queueData : queryConsumeQueueResponseBody.getQueueData()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("idx: " + i + "\n");

                stringBuilder.append(queueData.toString() + "\n");

                stringBuilder.append("======================================\n");

                System.out.print(stringBuilder.toString());
                i++;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #24
Source File: QueryConsumeQueueCommand.java    From rocketmq-4.3.0 with Apache License 2.0 4 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 topic = commandLine.getOptionValue("t").trim();
        int queueId = Integer.valueOf(commandLine.getOptionValue("q").trim());
        long index = Long.valueOf(commandLine.getOptionValue("i").trim());
        int count = Integer.valueOf(commandLine.getOptionValue("c", "10").trim());
        String broker = null;
        if (commandLine.hasOption("b")) {
            broker = commandLine.getOptionValue("b").trim();
        }
        String consumerGroup = null;
        if (commandLine.hasOption("g")) {
            consumerGroup = commandLine.getOptionValue("g").trim();
        }

        if (broker == null || broker == "") {
            TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);

            if (topicRouteData == null || topicRouteData.getBrokerDatas() == null
                || topicRouteData.getBrokerDatas().isEmpty()) {
                throw new Exception("No topic route data!");
            }

            broker = topicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(0L);
        }

        QueryConsumeQueueResponseBody queryConsumeQueueResponseBody = defaultMQAdminExt.queryConsumeQueue(
            broker, topic, queueId, index, count, consumerGroup
        );

        if (queryConsumeQueueResponseBody.getSubscriptionData() != null) {
            System.out.printf("Subscription data: \n%s\n", JSON.toJSONString(queryConsumeQueueResponseBody.getSubscriptionData(), true));
            System.out.print("======================================\n");
        }

        if (queryConsumeQueueResponseBody.getFilterData() != null) {
            System.out.printf("Filter data: \n%s\n", queryConsumeQueueResponseBody.getFilterData());
            System.out.print("======================================\n");
        }

        System.out.printf("Queue data: \nmax: %d, min: %d\n", queryConsumeQueueResponseBody.getMaxQueueIndex(),
            queryConsumeQueueResponseBody.getMinQueueIndex());
        System.out.print("======================================\n");

        if (queryConsumeQueueResponseBody.getQueueData() != null) {

            long i = index;
            for (ConsumeQueueData queueData : queryConsumeQueueResponseBody.getQueueData()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("idx: " + i + "\n");

                stringBuilder.append(queueData.toString() + "\n");

                stringBuilder.append("======================================\n");

                System.out.print(stringBuilder.toString());
                i++;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #25
Source File: QueryConsumeQueueCommand.java    From DDMQ with Apache License 2.0 4 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 topic = commandLine.getOptionValue("t").trim();
        int queueId = Integer.valueOf(commandLine.getOptionValue("q").trim());
        long index = Long.valueOf(commandLine.getOptionValue("i").trim());
        int count = Integer.valueOf(commandLine.getOptionValue("c", "10").trim());
        String broker = null;
        if (commandLine.hasOption("b")) {
            broker = commandLine.getOptionValue("b").trim();
        }
        String consumerGroup = null;
        if (commandLine.hasOption("g")) {
            consumerGroup = commandLine.getOptionValue("g").trim();
        }

        if (broker == null || broker == "") {
            TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);

            if (topicRouteData == null || topicRouteData.getBrokerDatas() == null
                || topicRouteData.getBrokerDatas().isEmpty()) {
                throw new Exception("No topic route data!");
            }

            broker = topicRouteData.getBrokerDatas().get(0).getBrokerAddrs().get(0L);
        }

        QueryConsumeQueueResponseBody queryConsumeQueueResponseBody = defaultMQAdminExt.queryConsumeQueue(
            broker, topic, queueId, index, count, consumerGroup
        );

        if (queryConsumeQueueResponseBody.getSubscriptionData() != null) {
            System.out.printf("Subscription data: \n%s\n", JSON.toJSONString(queryConsumeQueueResponseBody.getSubscriptionData(), true));
            System.out.print("======================================\n");
        }

        if (queryConsumeQueueResponseBody.getFilterData() != null) {
            System.out.printf("Filter data: \n%s\n", queryConsumeQueueResponseBody.getFilterData());
            System.out.print("======================================\n");
        }

        System.out.printf("Queue data: \nmax: %d, min: %d\n", queryConsumeQueueResponseBody.getMaxQueueIndex(),
            queryConsumeQueueResponseBody.getMinQueueIndex());
        System.out.print("======================================\n");

        if (queryConsumeQueueResponseBody.getQueueData() != null) {

            long i = index;
            for (ConsumeQueueData queueData : queryConsumeQueueResponseBody.getQueueData()) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("idx: " + i + "\n");

                stringBuilder.append(queueData.toString() + "\n");

                stringBuilder.append("======================================\n");

                System.out.print(stringBuilder.toString());
                i++;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        defaultMQAdminExt.shutdown();
    }
}
 
Example #26
Source File: MQAdminExt.java    From DDMQ with Apache License 2.0 2 votes vote down vote up
/**
 * query consume queue data
 *
 * @param brokerAddr broker ip address
 * @param topic topic
 * @param queueId id of queue
 * @param index start offset
 * @param count how many
 * @param consumerGroup group
 */
QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
    final String topic, final int queueId,
    final long index, final int count, final String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;
 
Example #27
Source File: MQAdminExt.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 2 votes vote down vote up
/**
 * query consume queue data
 *
 * @param brokerAddr broker ip address
 * @param topic topic
 * @param queueId id of queue
 * @param index start offset
 * @param count how many
 * @param consumerGroup group
 * @return
 * @throws InterruptedException
 * @throws RemotingTimeoutException
 * @throws RemotingSendRequestException
 * @throws RemotingConnectException
 * @throws MQClientException
 */
QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
                                        final String topic, final int queueId,
                                        final long index, final int count, final String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;
 
Example #28
Source File: MQAdminExt.java    From rocketmq-read with Apache License 2.0 2 votes vote down vote up
/**
 * query consume queue data
 *
 * @param brokerAddr broker ip address
 * @param topic topic
 * @param queueId id of queue
 * @param index start offset
 * @param count how many
 * @param consumerGroup group
 */
QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
    final String topic, final int queueId,
    final long index, final int count, final String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;
 
Example #29
Source File: MQAdminExt.java    From rocketmq-4.3.0 with Apache License 2.0 2 votes vote down vote up
/**
 * query consume queue data
 *
 * @param brokerAddr broker ip address
 * @param topic topic
 * @param queueId id of queue
 * @param index start offset
 * @param count how many
 * @param consumerGroup group
 */
QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
    final String topic, final int queueId,
    final long index, final int count, final String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;
 
Example #30
Source File: MQAdminExt.java    From rocketmq with Apache License 2.0 2 votes vote down vote up
/**
 * query consume queue data
 *
 * @param brokerAddr broker ip address
 * @param topic topic
 * @param queueId id of queue
 * @param index start offset
 * @param count how many
 * @param consumerGroup group
 */
QueryConsumeQueueResponseBody queryConsumeQueue(final String brokerAddr,
    final String topic, final int queueId,
    final long index, final int count, final String consumerGroup)
    throws InterruptedException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException, MQClientException;