Package com.alibaba.rocketmq.client.impl.consumer

Examples of com.alibaba.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl


        while (it.hasNext()) {
            Entry<String, MQConsumerInner> entry = it.next();
            MQConsumerInner impl = entry.getValue();
            if (impl != null) {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
                    consumer.getConsumerStatManager().recordSnapshotPeriodically();
                }
            }
        }
    }
View Full Code Here


        while (it.hasNext()) {
            Entry<String, MQConsumerInner> entry = it.next();
            MQConsumerInner impl = entry.getValue();
            if (impl != null) {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
                    consumer.getConsumerStatManager().logStatsPeriodically(entry.getKey(), this.clientId);
                }
            }
        }
    }
View Full Code Here

        return null;
    }


    public void resetOffset(String topic, String group, Map<MessageQueue, Long> offsetTable) {
        DefaultMQPushConsumerImpl consumer = null;
        try {
            MQConsumerInner impl = this.consumerTable.get(group);
            if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
                consumer = (DefaultMQPushConsumerImpl) impl;
            }
            else {
                log.info("[reset-offset] consumer dose not exist. group={}", group);
                return;
            }

            // 设置当前的 processQueue 为 dropped,从而使得当前的 pullRequest 以及
            // consumerRequest 处理结束并销毁
            ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable =
                    consumer.getRebalanceImpl().getProcessQueueTable();
            Iterator<MessageQueue> itr = processQueueTable.keySet().iterator();
            while (itr.hasNext()) {
                MessageQueue mq = itr.next();
                if (topic.equals(mq.getTopic())) {
                    ProcessQueue pq = processQueueTable.get(mq);
                    pq.setDroped(true);
                    pq.clear();
                }
            }

            // 更新消费队列的 offset 并提交到 broker
            Iterator<MessageQueue> iterator = offsetTable.keySet().iterator();
            while (iterator.hasNext()) {
                MessageQueue mq = iterator.next();
                consumer.updateConsumeOffset(mq, offsetTable.get(mq));
                log.info("[reset-offset] reset offsetTable. topic={}, group={}, mq={}, offset={}",
                    new Object[] { topic, group, mq, offsetTable.get(mq) });
            }
            consumer.getOffsetStore().persistAll(offsetTable.keySet());

            // 等待所有的 pullRequest 以及 consumerRequest 处理完成
            try {
                TimeUnit.SECONDS.sleep(10);
            }
            catch (InterruptedException e) {
                //
            }

            // 更新消费队列的 offset 并提交到 broker
            iterator = offsetTable.keySet().iterator();
            while (iterator.hasNext()) {
                MessageQueue mq = iterator.next();
                consumer.updateConsumeOffset(mq, offsetTable.get(mq));
                log.info("[reset-offset] reset offsetTable. topic={}, group={}, mq={}, offset={}",
                    new Object[] { topic, group, mq, offsetTable.get(mq) });
            }
            consumer.getOffsetStore().persistAll(offsetTable.keySet());

            // 真正清除被 dropped 的 processQueue,从而使得新的 rebalance 生效,生成新的 pullRequest
            // 以及 consumerRequest
            iterator = offsetTable.keySet().iterator();
            processQueueTable = consumer.getRebalanceImpl().getProcessQueueTable();
            while (iterator.hasNext()) {
                MessageQueue mq = iterator.next();
                processQueueTable.remove(mq);
            }
        }
        finally {
            // 放在 finally 主要是确保 rebalance 一定被执行
            consumer.getRebalanceImpl().doRebalance();
        }
    }
View Full Code Here


    public Map<MessageQueue, Long> getConsumerStatus(String topic, String group) {
        MQConsumerInner impl = this.consumerTable.get(group);
        if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
            DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
            return consumer.getOffsetStore().cloneOffsetTable(topic);
        }
        else if (impl != null && impl instanceof DefaultMQPullConsumerImpl) {
            DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) impl;
            return consumer.getOffsetStore().cloneOffsetTable(topic);
        }
        else {
            return Collections.EMPTY_MAP;
        }
    }
View Full Code Here

        while (it.hasNext()) {
            Entry<String, MQConsumerInner> entry = it.next();
            MQConsumerInner impl = entry.getValue();
            if (impl != null) {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
                    consumer.getConsumerStatManager().recordSnapshotPeriodically();
                }
            }
        }
    }
View Full Code Here

        while (it.hasNext()) {
            Entry<String, MQConsumerInner> entry = it.next();
            MQConsumerInner impl = entry.getValue();
            if (impl != null) {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
                    consumer.getConsumerStatManager().logStatsPeriodically(entry.getKey(), this.clientId);
                }
            }
        }
    }
View Full Code Here

        return null;
    }


    public void resetOffset(String topic, String group, Map<MessageQueue, Long> offsetTable) {
        DefaultMQPushConsumerImpl consumer = null;
        try {
            MQConsumerInner impl = this.consumerTable.get(group);
            if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
                consumer = (DefaultMQPushConsumerImpl) impl;
            }
            else {
                log.info("[reset-offset] consumer dose not exist. group={}", group);
                return;
            }

            // 设置当前的 processQueue 为 dropped,从而使得当前的 pullRequest 以及
            // consumerRequest 处理结束并销毁
            ConcurrentHashMap<MessageQueue, ProcessQueue> processQueueTable =
                    consumer.getRebalanceImpl().getProcessQueueTable();
            Iterator<MessageQueue> itr = processQueueTable.keySet().iterator();
            while (itr.hasNext()) {
                MessageQueue mq = itr.next();
                if (topic.equals(mq.getTopic())) {
                    ProcessQueue pq = processQueueTable.get(mq);
                    pq.setDroped(true);
                    pq.clear();
                }
            }

            // 更新消费队列的 offset 并提交到 broker
            Iterator<MessageQueue> iterator = offsetTable.keySet().iterator();
            while (iterator.hasNext()) {
                MessageQueue mq = iterator.next();
                consumer.updateConsumeOffset(mq, offsetTable.get(mq));
                log.info("[reset-offset] reset offsetTable. topic={}, group={}, mq={}, offset={}",
                    new Object[] { topic, group, mq, offsetTable.get(mq) });
            }
            consumer.getOffsetStore().persistAll(offsetTable.keySet());

            // 等待所有的 pullRequest 以及 consumerRequest 处理完成
            try {
                TimeUnit.SECONDS.sleep(10);
            }
            catch (InterruptedException e) {
                //
            }

            // 更新消费队列的 offset 并提交到 broker
            iterator = offsetTable.keySet().iterator();
            while (iterator.hasNext()) {
                MessageQueue mq = iterator.next();
                consumer.updateConsumeOffset(mq, offsetTable.get(mq));
                log.info("[reset-offset] reset offsetTable. topic={}, group={}, mq={}, offset={}",
                    new Object[] { topic, group, mq, offsetTable.get(mq) });
            }
            consumer.getOffsetStore().persistAll(offsetTable.keySet());

            // 真正清除被 dropped 的 processQueue,从而使得新的 rebalance 生效,生成新的 pullRequest
            // 以及 consumerRequest
            iterator = offsetTable.keySet().iterator();
            processQueueTable = consumer.getRebalanceImpl().getProcessQueueTable();
            while (iterator.hasNext()) {
                MessageQueue mq = iterator.next();
                processQueueTable.remove(mq);
            }
        }
        finally {
            // 放在 finally 主要是确保 rebalance 一定被执行
            consumer.getRebalanceImpl().doRebalance();
        }
    }
View Full Code Here


    public Map<MessageQueue, Long> getConsumerStatus(String topic, String group) {
        MQConsumerInner impl = this.consumerTable.get(group);
        if (impl != null && impl instanceof DefaultMQPushConsumerImpl) {
            DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
            return consumer.getOffsetStore().cloneOffsetTable(topic);
        }
        else if (impl != null && impl instanceof DefaultMQPullConsumerImpl) {
            DefaultMQPullConsumerImpl consumer = (DefaultMQPullConsumerImpl) impl;
            return consumer.getOffsetStore().cloneOffsetTable(topic);
        }
        else {
            return Collections.EMPTY_MAP;
        }
    }
View Full Code Here

        while (it.hasNext()) {
            Entry<String, MQConsumerInner> entry = it.next();
            MQConsumerInner impl = entry.getValue();
            if (impl != null) {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
                    consumer.getConsumerStatManager().recordSnapshotPeriodically();
                }
            }
        }
    }
View Full Code Here

        while (it.hasNext()) {
            Entry<String, MQConsumerInner> entry = it.next();
            MQConsumerInner impl = entry.getValue();
            if (impl != null) {
                if (impl instanceof DefaultMQPushConsumerImpl) {
                    DefaultMQPushConsumerImpl consumer = (DefaultMQPushConsumerImpl) impl;
                    consumer.getConsumerStatManager().logStatsPeriodically(entry.getKey(), this.clientId);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.alibaba.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.