Search in sources :

Example 6 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.

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 7 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.

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 8 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.

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)

Example 9 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.

the class SendMessageProcessorTest method testProcessRequest_PropertiesTooLong.

@Test
public void testProcessRequest_PropertiesTooLong() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PROPERTIES_SIZE_EXCEEDED, 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 10 with AppendMessageResult

use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.

the class SendMessageProcessorTest method testProcessRequest_FlushSlaveTimeout.

@Test
public void testProcessRequest_FlushSlaveTimeout() throws RemotingCommandException {
    when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.FLUSH_SLAVE_TIMEOUT, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
    assertPutResult(ResponseCode.FLUSH_SLAVE_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)

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