Java Code Examples for org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData#isClassFilterMode()

The following examples show how to use org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData#isClassFilterMode() . 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: MQClientInstance.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
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();
        if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
            Set<SubscriptionData> subscriptions = consumer.subscriptions();
            for (SubscriptionData sub : subscriptions) {
                if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
                    final String consumerGroup = consumer.groupName();
                    final String className = sub.getSubString();
                    final String topic = sub.getTopic();
                    final String filterClassSource = sub.getFilterClassSource();
                    try {
                        this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
                    } catch (Exception e) {
                        log.error("uploadFilterClassToAllFilterServer Exception", e);
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: DefaultMessageFilter.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isMessageMatched(SubscriptionData subscriptionData, Long tagsCode) {
    // 消息tagsCode 空
    if (tagsCode == null) {
        return true;
    }
    // 订阅数据 空
    if (null == subscriptionData) {
        return true;
    }
    // classFilter
    if (subscriptionData.isClassFilterMode())
        return true;
    // 订阅表达式 全匹配
    if (subscriptionData.getSubString().equals(SubscriptionData.SUB_ALL)) {
        return true;
    }
    // 订阅数据code数组 是否包含 消息tagsCode
    return subscriptionData.getCodeSet().contains(tagsCode.intValue());
}
 
Example 3
Source File: MQClientInstance.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
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();
        if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
            Set<SubscriptionData> subscriptions = consumer.subscriptions();
            for (SubscriptionData sub : subscriptions) {
                if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
                    final String consumerGroup = consumer.groupName();
                    final String className = sub.getSubString();
                    final String topic = sub.getTopic();
                    final String filterClassSource = sub.getFilterClassSource();
                    try {
                        this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
                    } catch (Exception e) {
                        log.error("uploadFilterClassToAllFilterServer Exception", e);
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: MQClientInstance.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
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();
        if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
            Set<SubscriptionData> subscriptions = consumer.subscriptions();
            for (SubscriptionData sub : subscriptions) {
                if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
                    final String consumerGroup = consumer.groupName();
                    final String className = sub.getSubString();
                    final String topic = sub.getTopic();
                    final String filterClassSource = sub.getFilterClassSource();
                    try {
                        this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
                    } catch (Exception e) {
                        log.error("uploadFilterClassToAllFilterServer Exception", e);
                    }
                }
            }
        }
    }
}
 
Example 5
Source File: DefaultMessageFilter.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isMessageMatched(SubscriptionData subscriptionData, Long tagsCode) {
    if (tagsCode == null) {
        return true;
    }

    if (null == subscriptionData) {
        return true;
    }

    if (subscriptionData.isClassFilterMode())
        return true;

    if (subscriptionData.getSubString().equals(SubscriptionData.SUB_ALL)) {
        return true;
    }

    return subscriptionData.getCodeSet().contains(tagsCode.intValue());
}
 
Example 6
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
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();
        if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
            Set<SubscriptionData> subscriptions = consumer.subscriptions();
            for (SubscriptionData sub : subscriptions) {
                if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
                    final String consumerGroup = consumer.groupName();
                    final String className = sub.getSubString();
                    final String topic = sub.getTopic();
                    final String filterClassSource = sub.getFilterClassSource();
                    try {
                        this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
                    } catch (Exception e) {
                        log.error("uploadFilterClassToAllFilterServer Exception", e);
                    }
                }
            }
        }
    }
}
 
Example 7
Source File: MQClientInstance.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
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();
//            如果消费者消息模式是push
            if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
//                获取消费者订阅信息
                Set<SubscriptionData> subscriptions = consumer.subscriptions();
                for (SubscriptionData sub : subscriptions) {
                    if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
                        final String consumerGroup = consumer.groupName();
                        final String className = sub.getSubString();
                        final String topic = sub.getTopic();
                        final String filterClassSource = sub.getFilterClassSource();
                        try {
//                            更新过滤类去所有过滤的server=》
                            this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
                        } catch (Exception e) {
                            log.error("uploadFilterClassToAllFilterServer Exception", e);
                        }
                    }
                }
            }
        }
    }
 
Example 8
Source File: MQClientInstance.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 上传FilterClass源码
 */
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();
        //如果消费模型是push模型
        if (ConsumeType.CONSUME_PASSIVELY == consumer.consumeType()) {
            Set<SubscriptionData> subscriptions = consumer.subscriptions();
            for (SubscriptionData sub : subscriptions) {
                if (sub.isClassFilterMode() && sub.getFilterClassSource() != null) {
                    final String consumerGroup = consumer.groupName();
                    final String className = sub.getSubString();
                    final String topic = sub.getTopic();
                    final String filterClassSource = sub.getFilterClassSource();
                    try {
                        this.uploadFilterClassToAllFilterServer(consumerGroup, className, topic, filterClassSource);
                    } catch (Exception e) {
                        log.error("uploadFilterClassToAllFilterServer Exception", e);
                    }
                }
            }
        }
    }
}