Search in sources :

Example 1 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SendMessageProcessorTest method testProcessRequest.

@Test
public void testProcessRequest() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK)));
    assertPutResult(ResponseCode.SUCCESS);
}
Also used : PutMessageResult(org.apache.rocketmq.store.PutMessageResult) MessageExtBrokerInner(org.apache.rocketmq.store.MessageExtBrokerInner) AppendMessageResult(org.apache.rocketmq.store.AppendMessageResult) Test(org.junit.Test)

Example 2 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SendMessageProcessorTest method testProcessRequest_WithHook.

@Test
public void testProcessRequest_WithHook() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK)));
    List<SendMessageHook> sendMessageHookList = new ArrayList<>();
    final SendMessageContext[] sendMessageContext = new SendMessageContext[1];
    SendMessageHook sendMessageHook = new SendMessageHook() {

        @Override
        public String hookName() {
            return null;
        }

        @Override
        public void sendMessageBefore(SendMessageContext context) {
            sendMessageContext[0] = context;
        }

        @Override
        public void sendMessageAfter(SendMessageContext context) {
        }
    };
    sendMessageHookList.add(sendMessageHook);
    sendMessageProcessor.registerSendMessageHook(sendMessageHookList);
    assertPutResult(ResponseCode.SUCCESS);
    System.out.println(sendMessageContext[0]);
    assertThat(sendMessageContext[0]).isNotNull();
    assertThat(sendMessageContext[0].getTopic()).isEqualTo(topic);
    assertThat(sendMessageContext[0].getProducerGroup()).isEqualTo(group);
}
Also used : PutMessageResult(org.apache.rocketmq.store.PutMessageResult) SendMessageContext(org.apache.rocketmq.broker.mqtrace.SendMessageContext) ArrayList(java.util.ArrayList) MessageExtBrokerInner(org.apache.rocketmq.store.MessageExtBrokerInner) AppendMessageResult(org.apache.rocketmq.store.AppendMessageResult) SendMessageHook(org.apache.rocketmq.broker.mqtrace.SendMessageHook) Test(org.junit.Test)

Example 3 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SendMessageProcessorTest method testProcessRequest_FlushTimeOut.

@Test
public void testProcessRequest_FlushTimeOut() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.FLUSH_DISK_TIMEOUT, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
    assertPutResult(ResponseCode.FLUSH_DISK_TIMEOUT);
}
Also used : PutMessageResult(org.apache.rocketmq.store.PutMessageResult) MessageExtBrokerInner(org.apache.rocketmq.store.MessageExtBrokerInner) AppendMessageResult(org.apache.rocketmq.store.AppendMessageResult) Test(org.junit.Test)

Example 4 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SendMessageProcessorTest method testProcessRequest_MessageIllegal.

@Test
public void testProcessRequest_MessageIllegal() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.MESSAGE_ILLEGAL, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
    assertPutResult(ResponseCode.MESSAGE_ILLEGAL);
}
Also used : PutMessageResult(org.apache.rocketmq.store.PutMessageResult) MessageExtBrokerInner(org.apache.rocketmq.store.MessageExtBrokerInner) AppendMessageResult(org.apache.rocketmq.store.AppendMessageResult) Test(org.junit.Test)

Example 5 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class SendMessageProcessorTest method testProcessRequest_WithMsgBack.

@Test
public void testProcessRequest_WithMsgBack() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK)));
    final RemotingCommand request = createSendMsgBackCommand(RequestCode.CONSUMER_SEND_MSG_BACK);
    sendMessageProcessor = new SendMessageProcessor(brokerController);
    final RemotingCommand response = sendMessageProcessor.processRequest(handlerContext, request);
    assertThat(response).isNotNull();
    assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) PutMessageResult(org.apache.rocketmq.store.PutMessageResult) MessageExtBrokerInner(org.apache.rocketmq.store.MessageExtBrokerInner) AppendMessageResult(org.apache.rocketmq.store.AppendMessageResult) Test(org.junit.Test)

Aggregations

AppendMessageResult (org.apache.rocketmq.store.AppendMessageResult)22 MessageExtBrokerInner (org.apache.rocketmq.store.MessageExtBrokerInner)22 PutMessageResult (org.apache.rocketmq.store.PutMessageResult)22 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)2 SendMessageContext (org.apache.rocketmq.broker.mqtrace.SendMessageContext)2 SendMessageHook (org.apache.rocketmq.broker.mqtrace.SendMessageHook)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2