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


Java MessageFilter类代码示例

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


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

示例1: PullRequest

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
public PullRequest(RemotingCommand requestCommand, Channel clientChannel, long timeoutMillis, long suspendTimestamp,
    long pullFromThisOffset, SubscriptionData subscriptionData,
    MessageFilter messageFilter) {
    this.requestCommand = requestCommand;
    this.clientChannel = clientChannel;
    this.timeoutMillis = timeoutMillis;
    this.suspendTimestamp = suspendTimestamp;
    this.pullFromThisOffset = pullFromThisOffset;
    this.subscriptionData = subscriptionData;
    this.messageFilter = messageFilter;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:12,代码来源:PullRequest.java

示例2: testGetMessage_withFilter_checkTagsCode

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
@Test
public void testGetMessage_withFilter_checkTagsCode() throws Exception {
    putMsg(master, topicCount, msgPerTopic);

    Thread.sleep(200);

    for (int i = 0; i < topicCount; i++) {
        String realTopic = topic + i;

        GetMessageResult getMessageResult = master.getMessage("test", realTopic, queueId, 0, 10000,
            new MessageFilter() {
                @Override
                public boolean isMatchedByConsumeQueue(Long tagsCode, ConsumeQueueExt.CqExtUnit cqExtUnit) {
                    if (tagsCode != null && tagsCode <= ConsumeQueueExt.MAX_ADDR) {
                        return false;
                    }
                    return true;
                }

                @Override
                public boolean isMatchedByCommitLog(ByteBuffer msgBuffer, Map<String, String> properties) {
                    return true;
                }
            });
        assertThat(getMessageResult.getMessageCount()).isEqualTo(msgPerTopic);
    }
}
 
开发者ID:apache,项目名称:rocketmq,代码行数:28,代码来源:MessageStoreWithFilterTest.java

示例3: getMessage

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
@Override
public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
                                   int maxMsgNums, final MessageFilter messageFilter) {
    return next.getMessage(group, topic, queueId, offset, maxMsgNums, messageFilter);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:6,代码来源:AbstractPluginMessageStore.java

示例4: queryConsumeQueue

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
private RemotingCommand queryConsumeQueue(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    QueryConsumeQueueRequestHeader requestHeader =
        (QueryConsumeQueueRequestHeader) request.decodeCommandCustomHeader(QueryConsumeQueueRequestHeader.class);

    RemotingCommand response = RemotingCommand.createResponseCommand(null);

    ConsumeQueue consumeQueue = this.brokerController.getMessageStore().getConsumeQueue(requestHeader.getTopic(),
        requestHeader.getQueueId());
    if (consumeQueue == null) {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("%[email protected]%s is not exist!", requestHeader.getQueueId(), requestHeader.getTopic()));
        return response;
    }

    QueryConsumeQueueResponseBody body = new QueryConsumeQueueResponseBody();
    response.setCode(ResponseCode.SUCCESS);
    response.setBody(body.encode());

    body.setMaxQueueIndex(consumeQueue.getMaxOffsetInQueue());
    body.setMinQueueIndex(consumeQueue.getMinOffsetInQueue());

    MessageFilter messageFilter = null;
    if (requestHeader.getConsumerGroup() != null) {
        SubscriptionData subscriptionData = this.brokerController.getConsumerManager().findSubscriptionData(
            requestHeader.getConsumerGroup(), requestHeader.getTopic()
        );
        body.setSubscriptionData(subscriptionData);
        if (subscriptionData == null) {
            body.setFilterData(String.format("%[email protected]%s is not online!", requestHeader.getConsumerGroup(), requestHeader.getTopic()));
        } else {
            ConsumerFilterData filterData = this.brokerController.getConsumerFilterManager()
                .get(requestHeader.getTopic(), requestHeader.getConsumerGroup());
            body.setFilterData(JSON.toJSONString(filterData, true));

            messageFilter = new ExpressionMessageFilter(subscriptionData, filterData,
                this.brokerController.getConsumerFilterManager());
        }
    }

    SelectMappedBufferResult result = consumeQueue.getIndexBuffer(requestHeader.getIndex());
    if (result == null) {
        response.setRemark(String.format("Index %d of %[email protected]%s is not exist!", requestHeader.getIndex(), requestHeader.getQueueId(), requestHeader.getTopic()));
        return response;
    }
    try {
        List<ConsumeQueueData> queues = new ArrayList<>();
        for (int i = 0; i < result.getSize() && i < requestHeader.getCount() * ConsumeQueue.CQ_STORE_UNIT_SIZE; i += ConsumeQueue.CQ_STORE_UNIT_SIZE) {
            ConsumeQueueData one = new ConsumeQueueData();
            one.setPhysicOffset(result.getByteBuffer().getLong());
            one.setPhysicSize(result.getByteBuffer().getInt());
            one.setTagsCode(result.getByteBuffer().getLong());

            if (!consumeQueue.isExtAddr(one.getTagsCode())) {
                queues.add(one);
                continue;
            }

            ConsumeQueueExt.CqExtUnit cqExtUnit = consumeQueue.getExt(one.getTagsCode());
            if (cqExtUnit != null) {
                one.setExtendDataJson(JSON.toJSONString(cqExtUnit));
                if (cqExtUnit.getFilterBitMap() != null) {
                    one.setBitMap(BitsArray.create(cqExtUnit.getFilterBitMap()).toString());
                }
                if (messageFilter != null) {
                    one.setEval(messageFilter.isMatchedByConsumeQueue(cqExtUnit.getTagsCode(), cqExtUnit));
                }
            } else {
                one.setMsg("Cq extend not exist!addr: " + one.getTagsCode());
            }

            queues.add(one);
        }
        body.setQueueData(queues);
    } finally {
        result.release();
    }

    return response;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:80,代码来源:AdminBrokerProcessor.java

示例5: getMessageFilter

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
public MessageFilter getMessageFilter() {
    return messageFilter;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:4,代码来源:PullRequest.java

示例6: getMessage

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
@Override
public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
    int maxMsgNums, final MessageFilter messageFilter) {
    return next.getMessage(group, topic, queueId, offset, maxMsgNums, messageFilter);
}
 
开发者ID:apache,项目名称:rocketmq,代码行数:6,代码来源:AbstractPluginMessageStore.java

示例7: queryConsumeQueue

import org.apache.rocketmq.store.MessageFilter; //导入依赖的package包/类
private RemotingCommand queryConsumeQueue(ChannelHandlerContext ctx,
    RemotingCommand request) throws RemotingCommandException {
    QueryConsumeQueueRequestHeader requestHeader =
        (QueryConsumeQueueRequestHeader) request.decodeCommandCustomHeader(QueryConsumeQueueRequestHeader.class);

    RemotingCommand response = RemotingCommand.createResponseCommand(null);

    ConsumeQueue consumeQueue = this.brokerController.getMessageStore().getConsumeQueue(requestHeader.getTopic(),
        requestHeader.getQueueId());
    if (consumeQueue == null) {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("%[email protected]%s is not exist!", requestHeader.getQueueId(), requestHeader.getTopic()));
        return response;
    }

    QueryConsumeQueueResponseBody body = new QueryConsumeQueueResponseBody();
    response.setCode(ResponseCode.SUCCESS);
    response.setBody(body.encode());

    body.setMaxQueueIndex(consumeQueue.getMaxOffsetInQueue());
    body.setMinQueueIndex(consumeQueue.getMinOffsetInQueue());

    MessageFilter messageFilter = null;
    if (requestHeader.getConsumerGroup() != null) {
        SubscriptionData subscriptionData = this.brokerController.getConsumerManager().findSubscriptionData(
            requestHeader.getConsumerGroup(), requestHeader.getTopic()
        );
        body.setSubscriptionData(subscriptionData);
        if (subscriptionData == null) {
            body.setFilterData(String.format("%[email protected]%s is not online!", requestHeader.getConsumerGroup(), requestHeader.getTopic()));
        } else {
            ConsumerFilterData filterData = this.brokerController.getConsumerFilterManager()
                .get(requestHeader.getTopic(), requestHeader.getConsumerGroup());
            body.setFilterData(JSON.toJSONString(filterData, true));

            messageFilter = new ExpressionMessageFilter(subscriptionData, filterData,
                this.brokerController.getConsumerFilterManager());
        }
    }

    SelectMappedBufferResult result = consumeQueue.getIndexBuffer(requestHeader.getIndex());
    if (result == null) {
        response.setRemark(String.format("Index %d of %[email protected]%s is not exist!", requestHeader.getIndex(), requestHeader.getQueueId(), requestHeader.getTopic()));
        return response;
    }
    try {
        List<ConsumeQueueData> queues = new ArrayList<>();
        for (int i = 0; i < result.getSize() && i < requestHeader.getCount() * ConsumeQueue.CQ_STORE_UNIT_SIZE; i += ConsumeQueue.CQ_STORE_UNIT_SIZE) {
            ConsumeQueueData one = new ConsumeQueueData();
            one.setPhysicOffset(result.getByteBuffer().getLong());
            one.setPhysicSize(result.getByteBuffer().getInt());
            one.setTagsCode(result.getByteBuffer().getLong());

            if (!consumeQueue.isExtAddr(one.getTagsCode())) {
                queues.add(one);
                continue;
            }

            ConsumeQueueExt.CqExtUnit cqExtUnit = consumeQueue.getExt(one.getTagsCode());
            if (cqExtUnit != null) {
                one.setExtendDataJson(JSON.toJSONString(cqExtUnit));
                if (cqExtUnit.getFilterBitMap() != null) {
                    one.setBitMap(BitsArray.create(cqExtUnit.getFilterBitMap()).toString());
                }
                if (messageFilter != null) {
                    one.setEval(messageFilter.isMatchedByConsumeQueue(cqExtUnit.getTagsCode(), cqExtUnit));
                }
            } else {
                one.setMsg("Cq extend not exist!addr: " + one.getTagsCode());
            }

            queues.add(one);
        }
        body.setQueueData(queues);
    } finally {
        result.release();
    }

    return response;
}
 
开发者ID:apache,项目名称:rocketmq,代码行数:81,代码来源:AdminBrokerProcessor.java


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