org.apache.rocketmq.store.GetMessageStatus Java Examples

The following examples show how to use org.apache.rocketmq.store.GetMessageStatus. 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: PullMessageProcessorTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #3
Source File: PullMessageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(SubscriptionData.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #4
Source File: PullMessageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #5
Source File: PullMessageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #6
Source File: PullMessageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #7
Source File: PullMessageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #8
Source File: PullMessageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #9
Source File: PullMessageProcessorTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #10
Source File: PullMessageProcessorTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #11
Source File: PullMessageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(SubscriptionData.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #12
Source File: PullMessageProcessorTest.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(SubscriptionData.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #13
Source File: PullMessageProcessorTest.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(SubscriptionData.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #14
Source File: PullMessageProcessorTest.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #15
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 #16
Source File: TransactionalMessageBridgeTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult(GetMessageStatus status) {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(status);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #17
Source File: PullMessageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #18
Source File: PullMessageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #19
Source File: PullMessageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #20
Source File: DLedgerCommitlogTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testPutAndGetMessage() throws Exception {
    String base =  createBaseDir();
    String peers = String.format("n0-localhost:%d", nextPort());
    String group = UUID.randomUUID().toString();
    DefaultMessageStore messageStore = createDledgerMessageStore(base, group, "n0", peers, null, false, 0);
    Thread.sleep(1000);
    String topic = UUID.randomUUID().toString();

    List<PutMessageResult> results = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        MessageExtBrokerInner msgInner =
            i < 5 ? buildMessage() : buildIPv6HostMessage();
        msgInner.setTopic(topic);
        msgInner.setQueueId(0);
        PutMessageResult putMessageResult = messageStore.putMessage(msgInner);
        results.add(putMessageResult);
        Assert.assertEquals(PutMessageStatus.PUT_OK, putMessageResult.getPutMessageStatus());
        Assert.assertEquals(i, putMessageResult.getAppendMessageResult().getLogicsOffset());
    }
    Thread.sleep(100);
    Assert.assertEquals(0, messageStore.getMinOffsetInQueue(topic, 0));
    Assert.assertEquals(10, messageStore.getMaxOffsetInQueue(topic, 0));
    Assert.assertEquals(0, messageStore.dispatchBehindBytes());
    GetMessageResult getMessageResult =  messageStore.getMessage("group", topic, 0, 0, 32, null);
    Assert.assertEquals(GetMessageStatus.FOUND, getMessageResult.getStatus());

    Assert.assertEquals(10, getMessageResult.getMessageBufferList().size());
    Assert.assertEquals(10, getMessageResult.getMessageMapedList().size());

    for (int i = 0; i < results.size(); i++) {
        ByteBuffer buffer = getMessageResult.getMessageBufferList().get(i);
        MessageExt messageExt = MessageDecoder.decode(buffer);
        Assert.assertEquals(i, messageExt.getQueueOffset());
        Assert.assertEquals(results.get(i).getAppendMessageResult().getMsgId(), messageExt.getMsgId());
        Assert.assertEquals(results.get(i).getAppendMessageResult().getWroteOffset(), messageExt.getCommitLogOffset());
    }
    messageStore.destroy();
    messageStore.shutdown();
}
 
Example #21
Source File: PullMessageProcessorTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #22
Source File: PullMessageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}
 
Example #23
Source File: PullMessageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #24
Source File: TransactionalMessageBridgeTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult(GetMessageStatus status) {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(status);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #25
Source File: PullMessageProcessorTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #26
Source File: PullMessageProcessorTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult() {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #27
Source File: DeFiPluginMessageStoreTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetMessage(){
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.FOUND);
    getMessageResult.setNextBeginOffset(1);
    when(messageStore.getMessage(group,topic,1,0,0,null)).thenReturn(getMessageResult);
    GetMessageResult result = deFiPluginMessageStore.getMessage(group,topic,1,0,0,null);
    assertThat(result.getStatus()).isEqualTo(GetMessageStatus.FOUND);
    assertThat(result.getNextBeginOffset()).isEqualTo(1);
}
 
Example #28
Source File: TransactionalMessageBridgeTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private GetMessageResult createGetMessageResult(GetMessageStatus status) {
    GetMessageResult getMessageResult = new GetMessageResult();
    getMessageResult.setStatus(status);
    getMessageResult.setMinOffset(100);
    getMessageResult.setMaxOffset(1024);
    getMessageResult.setNextBeginOffset(516);
    return getMessageResult;
}
 
Example #29
Source File: PullMessageProcessorTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_MsgWasRemoving() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.MESSAGE_WAS_REMOVING);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_RETRY_IMMEDIATELY);
}
 
Example #30
Source File: PullMessageProcessorTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessRequest_NoMsgInQueue() throws RemotingCommandException {
    GetMessageResult getMessageResult = createGetMessageResult();
    getMessageResult.setStatus(GetMessageStatus.NO_MESSAGE_IN_QUEUE);
    when(messageStore.getMessage(anyString(), anyString(), anyInt(), anyLong(), anyInt(), any(ExpressionMessageFilter.class))).thenReturn(getMessageResult);

    final RemotingCommand request = createPullMsgCommand(RequestCode.PULL_MESSAGE);
    RemotingCommand response = pullMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.PULL_OFFSET_MOVED);
}