当前位置: 首页>>代码示例>>Java>>正文


Java ConsumeType类代码示例

本文整理汇总了Java中com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType的典型用法代码示例。如果您正苦于以下问题:Java ConsumeType类的具体用法?Java ConsumeType怎么用?Java ConsumeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConsumeType类属于com.alibaba.rocketmq.common.protocol.heartbeat包,在下文中一共展示了ConsumeType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerConsumer

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo,
        ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
        final Set<SubscriptionData> subList) {

    ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
    if (null == consumerGroupInfo) {
        ConsumerGroupInfo tmp = new ConsumerGroupInfo(group, consumeType, messageModel, consumeFromWhere);
        ConsumerGroupInfo prev = this.consumerTable.putIfAbsent(group, tmp);
        consumerGroupInfo = prev != null ? prev : tmp;
    }

    boolean r1 =
            consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
                consumeFromWhere);

    boolean r2 = consumerGroupInfo.updateSubscription(subList);

    if (r1 || r2) {
        this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
    }

    return r1 || r2;
}
 
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:24,代码来源:ConsumerManager.java

示例2: uploadFilterClassSource

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
private void uploadFilterClassSource() {
    Iterator<Entry<String, MQConsumerInner>> it = this.consumerTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, MQConsumerInner> next = it.next();
        MQConsumerInner consumer = next.getValue();
        // 只支持PushConsumer
        if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
            Set<SubscriptionData> subscriptions = consumer.subscriptions();
            for (SubscriptionData sub : subscriptions) {
                if (sub.isClassFilterMode()) {
                    final String consumerGroup = consumer.groupName();
                    final String className = sub.getSubString();
                    final String topic = sub.getTopic();
                    try {
                        this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic);
                    }
                    catch (Exception e) {
                        log.error("uploadFilterClassToAllFilterServer Exception", e);
                    }
                }
            }
        }
    }
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:25,代码来源:MQClientInstance.java

示例3: updateChannel

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
/**
 * 返回值表示是否发生变更
 */
public boolean updateChannel(final ClientChannelInfo clientChannelInfo, ConsumeType consumeType,
        MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
    boolean updated = false;
    this.consumeType = consumeType;
    this.messageModel = messageModel;
    this.consumeFromWhere = consumeFromWhere;

    ClientChannelInfo info = this.channelInfoTable.get(clientChannelInfo.getChannel());
    if (null == info) {
        ClientChannelInfo prev =
                this.channelInfoTable.put(clientChannelInfo.getChannel(), clientChannelInfo);
        if (null == prev) {
            log.info("new consumer connected, group: {} {} {} channel: {}", this.groupName, consumeType,
                messageModel, clientChannelInfo.toString());
            updated = true;
        }

        info = clientChannelInfo;
    }

    this.lastUpdateTimestamp = System.currentTimeMillis();
    info.setLastUpdateTimestamp(this.lastUpdateTimestamp);

    return updated;
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:29,代码来源:ConsumerGroupInfo.java

示例4: registerConsumer

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
/**
 * 返回是否有变化
 */
public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo,
        ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
        final Set<SubscriptionData> subList) {
    ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
    if (null == consumerGroupInfo) {
        ConsumerGroupInfo tmp = new ConsumerGroupInfo(group, consumeType, messageModel, consumeFromWhere);
        ConsumerGroupInfo prev = this.consumerTable.putIfAbsent(group, tmp);
        consumerGroupInfo = prev != null ? prev : tmp;
    }

    boolean r1 =
            consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
                consumeFromWhere);
    boolean r2 = consumerGroupInfo.updateSubscription(subList);

    if (r1 || r2) {
        this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
    }

    return r1 || r2;
}
 
开发者ID:diwayou,项目名称:rocketmq-all-trans,代码行数:25,代码来源:ConsumerManager.java

示例5: ConsumerGroupInfo

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public ConsumerGroupInfo(String groupName, ConsumeType consumeType, MessageModel messageModel,
        ConsumeFromWhere consumeFromWhere) {
    this.groupName = groupName;
    this.consumeType = consumeType;
    this.messageModel = messageModel;
    this.consumeFromWhere = consumeFromWhere;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:8,代码来源:ConsumerGroupInfo.java

示例6: updateChannel

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public boolean updateChannel(final ClientChannelInfo infoNew, ConsumeType consumeType,
        MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
    boolean updated = false;
    this.consumeType = consumeType;
    this.messageModel = messageModel;
    this.consumeFromWhere = consumeFromWhere;

    ClientChannelInfo infoOld = this.channelInfoTable.get(infoNew.getChannel());
    if (null == infoOld) { //原来没有注册对应的通道。
        //把新的通道注册进来 , 先进入的线程能够进入if 分支。
        ClientChannelInfo prev = this.channelInfoTable.put(infoNew.getChannel(), infoNew);
        if (null == prev) {
            log.info("new consumer connected, group: {} {} {} channel: {}", this.groupName, consumeType,
                messageModel, infoNew.toString());
            updated = true;
        }

        infoOld = infoNew;
    }
    else { //必须是相同的clientid 才能更新消费者通道信息。
        if (!infoOld.getClientId().equals(infoNew.getClientId())) {
            log.error(
                "[BUG] consumer channel exist in broker, but clientId not equal. GROUP: {} OLD: {} NEW: {} ",
                this.groupName,//
                infoOld.toString(),//
                infoNew.toString());
            this.channelInfoTable.put(infoNew.getChannel(), infoNew); //clientid不同的时候 ,也认为是加入新的消费者通道信息。
        }
    }

    this.lastUpdateTimestamp = System.currentTimeMillis();
    infoOld.setLastUpdateTimestamp(this.lastUpdateTimestamp);

    return updated;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:36,代码来源:ConsumerGroupInfo.java

示例7: registerConsumer

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
/**
 * 把 消费者(用clientChannelInfo 标识) 注册到指定的消费者分组(group),, 并且包含订阅元数据。
 * (消费类型, 消费模式, 位点类型,订阅的topic列表 。)
 * @param group
 * @param clientChannelInfo
 * @param consumeType
 * @param messageModel
 * @param consumeFromWhere
 * @param subList
 * @return
 */
public boolean registerConsumer(final String group, final ClientChannelInfo clientChannelInfo,
        ConsumeType consumeType, MessageModel messageModel, ConsumeFromWhere consumeFromWhere,
        final Set<SubscriptionData> subList) {
    ConsumerGroupInfo consumerGroupInfo = this.consumerTable.get(group);
    if (null == consumerGroupInfo) {
        ConsumerGroupInfo tmp = new ConsumerGroupInfo(group, consumeType, messageModel, consumeFromWhere);
        ConsumerGroupInfo prev = this.consumerTable.putIfAbsent(group, tmp);
        consumerGroupInfo = prev != null ? prev : tmp;
    }

    //把消费者通道(对应一个clientid ,默认[email protected])注册到消费者分组下。
    boolean r1 =
            consumerGroupInfo.updateChannel(clientChannelInfo, consumeType, messageModel,
                consumeFromWhere);
    boolean r2 = consumerGroupInfo.updateSubscription(subList);

    if (r1 || r2) { //消费者被加入到消费者分组(r1) || 消费者分组增加或者删除了对topic的订阅 , 则给分组中的所有消费者发送
        //消费者id的变更通知, 启动client的rebalance (但这里有一点疑问, 如果消费者退出消费者分组,也应该启动消费者id 的变更通知的。
        // 仔细想一下,因为这里是消费者注册操作, 所以当然是消费者加入消费者分组!!!而消费者退出则应该通过其他的心跳操作来解决。

        //所谓rebalance ,以集群消费为例,其实就是一个消费者分组中的消费者要分摊消费topic下的所有消息。
        //而具体的rebalance算法是按照topic来做的 ,具体是:
        //每一个消费者client 收到reblance指令以后,看自己订阅了哪些topic ,然后按topic分别做rebalance .

        //而每一个topic内的rebalance操作如下:
        //先从client本地缓存的路由表中获取topic归属的brokername下的broker master .
        //然后问broker master要订阅者clientid列表, 然后把topic下的消费队列按均摊算法大致均匀分配给各个clientid ,
        //退出某一个队列的消费者放手(把位点更新到broker)  , 而加入队列的消费者接手(把放手的那个消费者位点拿过来以拉的方式消费)。
        // )
        this.consumerIdsChangeListener.consumerIdsChanged(group, consumerGroupInfo.getAllChannel());
    }

    return r1 || r2;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:46,代码来源:ConsumerManager.java

示例8: updateChannel

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public boolean updateChannel(final ClientChannelInfo infoNew, ConsumeType consumeType,
        MessageModel messageModel, ConsumeFromWhere consumeFromWhere) {
    boolean updated = false;
    this.consumeType = consumeType;
    this.messageModel = messageModel;
    this.consumeFromWhere = consumeFromWhere;

    ClientChannelInfo infoOld = this.channelInfoTable.get(infoNew.getChannel());
    if (null == infoOld) {
        ClientChannelInfo prev = this.channelInfoTable.put(infoNew.getChannel(), infoNew);
        if (null == prev) {
            log.info("new consumer connected, group: {} {} {} channel: {}", this.groupName, consumeType,
                messageModel, infoNew.toString());
            updated = true;
        }

        infoOld = infoNew;
    }
    else {
        if (!infoOld.getClientId().equals(infoNew.getClientId())) {
            log.error(
                "[BUG] consumer channel exist in broker, but clientId not equal. GROUP: {} OLD: {} NEW: {} ",
                this.groupName,//
                infoOld.toString(),//
                infoNew.toString());
            this.channelInfoTable.put(infoNew.getChannel(), infoNew);
        }
    }

    this.lastUpdateTimestamp = System.currentTimeMillis();
    infoOld.setLastUpdateTimestamp(this.lastUpdateTimestamp);

    return updated;
}
 
开发者ID:medusar,项目名称:rocketmq-commet,代码行数:35,代码来源:ConsumerGroupInfo.java

示例9: consumeType

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
@Override
public ConsumeType consumeType() {
    return ConsumeType.CONSUME_ACTIVELY;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:5,代码来源:RebalancePullImpl.java

示例10: consumeType

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
@Override
public ConsumeType consumeType() {
    return ConsumeType.CONSUME_PASSIVELY;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:5,代码来源:DefaultMQPushConsumerImpl.java

示例11: consumeTypeDesc

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public String consumeTypeDesc() {
    if (this.count != 0) {
        return this.getConsumeType() == ConsumeType.CONSUME_ACTIVELY ? "PULL" : "PUSH";
    }
    return "";
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:7,代码来源:ConsumerProgressSubCommand.java

示例12: messageModelDesc

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public String messageModelDesc() {
    if (this.count != 0 && this.getConsumeType() == ConsumeType.CONSUME_PASSIVELY) {
        return this.getMessageModel().toString();
    }
    return "";
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:7,代码来源:ConsumerProgressSubCommand.java

示例13: getConsumeType

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public ConsumeType getConsumeType() {
    return consumeType;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:4,代码来源:ConsumerProgressSubCommand.java

示例14: setConsumeType

import com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType; //导入依赖的package包/类
public void setConsumeType(ConsumeType consumeType) {
    this.consumeType = consumeType;
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:4,代码来源:ConsumerProgressSubCommand.java


注:本文中的com.alibaba.rocketmq.common.protocol.heartbeat.ConsumeType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。