當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。