org.apache.rocketmq.store.MessageFilter Java Examples

The following examples show how to use org.apache.rocketmq.store.MessageFilter. 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: DeFiPluginMessageStore.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
@Override
public GetMessageResult getMessage(String group, String topic, int queueId, long offset,
    int maxMsgNums, final MessageFilter messageFilter) {
    long startTime = System.nanoTime();
    GetMessageResult getMessageResult
        = next.getMessage(group, topic, queueId, offset, maxMsgNums, messageFilter);

    if (getMessageResult.getStatus().equals(GetMessageStatus.FOUND)) {
        this.deFiQueueManager.recordLastDeliverOffset(group, topic, queueId, getMessageResult.getNextBeginOffset());
    }

    long eclipseNanoTime = System.nanoTime() - startTime;
    pluginStoreStatService.recordGetTime(eclipseNanoTime);

    return getMessageResult;
}
 
Example #2
Source File: MessageStoreWithFilterTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #3
Source File: MessageStoreWithFilterTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #4
Source File: TransactionalMessageBridgeTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHalfMessageNull() {
    when(messageStore
            .getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), ArgumentMatchers.nullable(MessageFilter.class)))
            .thenReturn(null);
    PullResult result = transactionBridge.getHalfMessage(0, 0, 1);
    assertThat(result).isNull();
}
 
Example #5
Source File: TransactionalMessageBridgeTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetHalfMessageStatusFound() {
    when(messageStore
            .getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), ArgumentMatchers.nullable(MessageFilter.class)))
            .thenReturn(createGetMessageResult(GetMessageStatus.FOUND));
    PullResult result = transactionBridge.getHalfMessage(0, 0, 1);
    assertThat(result.getPullStatus()).isEqualTo(PullStatus.FOUND);
}
 
Example #6
Source File: PullRequest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #7
Source File: PullRequest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: MessageStoreWithFilterTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #9
Source File: PullRequest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: PullRequest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #11
Source File: PullRequest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: MessageStoreWithFilterTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #13
Source File: PullRequest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #14
Source File: MessageStoreWithFilterTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example #15
Source File: AbstractPluginMessageStore.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #16
Source File: PullRequest.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public MessageFilter getMessageFilter() {
    return messageFilter;
}
 
Example #17
Source File: TransactionalMessageBridgeTest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetOpMessage() {
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(),  ArgumentMatchers.nullable(MessageFilter.class))).thenReturn(createGetMessageResult(GetMessageStatus.NO_MESSAGE_IN_QUEUE));
    PullResult result = transactionBridge.getOpMessage(0, 0, 1);
    assertThat(result.getPullStatus()).isEqualTo(PullStatus.NO_NEW_MSG);
}
 
Example #18
Source File: TransactionalMessageBridgeTest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetHalfMessage() {
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(),  ArgumentMatchers.nullable(MessageFilter.class))).thenReturn(createGetMessageResult(GetMessageStatus.NO_MESSAGE_IN_QUEUE));
    PullResult result = transactionBridge.getHalfMessage(0, 0, 1);
    assertThat(result.getPullStatus()).isEqualTo(PullStatus.NO_NEW_MSG);
}
 
Example #19
Source File: PullRequest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public MessageFilter getMessageFilter() {
    return messageFilter;
}
 
Example #20
Source File: AbstractPluginMessageStore.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #21
Source File: AbstractPluginMessageStore.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #22
Source File: PullRequest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public MessageFilter getMessageFilter() {
    return messageFilter;
}
 
Example #23
Source File: PullRequest.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
public MessageFilter getMessageFilter() {
    return messageFilter;
}
 
Example #24
Source File: PullRequest.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public MessageFilter getMessageFilter() {
    return messageFilter;
}
 
Example #25
Source File: TransactionalMessageBridgeTest.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetHalfMessage() {
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(),  ArgumentMatchers.nullable(MessageFilter.class))).thenReturn(createGetMessageResult(GetMessageStatus.NO_MESSAGE_IN_QUEUE));
    PullResult result = transactionBridge.getHalfMessage(0, 0, 1);
    assertThat(result.getPullStatus()).isEqualTo(PullStatus.NO_NEW_MSG);
}
 
Example #26
Source File: AbstractPluginMessageStore.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #27
Source File: AbstractPluginMessageStore.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #28
Source File: TransactionalMessageBridgeTest.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetOpMessage() {
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(),  ArgumentMatchers.nullable(MessageFilter.class))).thenReturn(createGetMessageResult(GetMessageStatus.NO_MESSAGE_IN_QUEUE));
    PullResult result = transactionBridge.getOpMessage(0, 0, 1);
    assertThat(result.getPullStatus()).isEqualTo(PullStatus.NO_NEW_MSG);
}
 
Example #29
Source File: TransactionalMessageBridgeTest.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetHalfMessage() {
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(),  ArgumentMatchers.nullable(MessageFilter.class))).thenReturn(createGetMessageResult(GetMessageStatus.NO_MESSAGE_IN_QUEUE));
    PullResult result = transactionBridge.getHalfMessage(0, 0, 1);
    assertThat(result.getPullStatus()).isEqualTo(PullStatus.NO_NEW_MSG);
}
 
Example #30
Source File: PullRequest.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public MessageFilter getMessageFilter() {
    return messageFilter;
}