private void executeByCondition(String brokerName, String queueId, long offset, long timeValueBegin, long timeValueEnd) {
        MessageQueue mq = new MessageQueue(topic, brokerName, Integer.parseInt(queueId));
        try {
            long minOffset = defaultMQPullConsumer.minOffset(mq);
            long maxOffset = defaultMQPullConsumer.maxOffset(mq);
            if (timeValueBegin > 0) {
                minOffset = defaultMQPullConsumer.searchOffset(mq, timeValueBegin);
            }
            if (timeValueEnd > 0) {
                maxOffset = defaultMQPullConsumer.searchOffset(mq, timeValueEnd);
            }
            if (offset > maxOffset) {
                System.out.printf("%s no matched msg, offset=%s\n", mq, offset);
                return;
            }
            minOffset = minOffset > offset ? minOffset : offset;
            if (maxOffset - minOffset > messageCount) {
                System.out.printf("The oldler %d message will be provided\n", messageCount);
                maxOffset = minOffset + messageCount - 1;
            }

            pullMessageByQueue(mq, minOffset, maxOffset);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@Test
    public void testExecuteByCondition() throws SubCommandException {
        PrintStream out = System.out;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        System.setOut(new PrintStream(bos));
        Options options = ServerUtil.buildCommandlineOptions(new Options());

        String[] subargs = new String[] {"-t mytopic", "-b localhost", "-i 0", "-n localhost:9876"};
        CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin " + consumeMessageCommand.commandName(),
            subargs, consumeMessageCommand.buildCommandlineOptions(options), new DefaultParser());
        assignPullResult();
        consumeMessageCommand.execute(commandLine, options, null);
        System.setOut(out);
        String s = new String(bos.toByteArray(), StandardCharsets.UTF_8);
        Assert.assertTrue(s.contains("Consume ok"));
    }