Search in sources :

Example 6 with MessageClientExt

use of org.apache.rocketmq.common.message.MessageClientExt in project rocketmq by apache.

the class QueryMsgByIdIT method testQueryMsg.

@Test
public void testQueryMsg() {
    int msgSize = 20;
    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    consumer.getListener().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
    Assert.assertEquals("Not all are consumed", 0, VerifyUtils.verify(producer.getAllMsgBody(), consumer.getListener().getAllMsgBody()));
    MessageExt recvMsg = (MessageExt) consumer.getListener().getFirstMsg();
    MessageExt queryMsg = null;
    try {
        TestUtils.waitForMoment(3000);
        queryMsg = producer.getProducer().viewMessage(((MessageClientExt) recvMsg).getOffsetMsgId());
    } catch (Exception e) {
    }
    assertThat(queryMsg).isNotNull();
    assertThat(new String(queryMsg.getBody())).isEqualTo(new String(recvMsg.getBody()));
}
Also used : MessageClientExt(org.apache.rocketmq.common.message.MessageClientExt) MessageExt(org.apache.rocketmq.common.message.MessageExt) Test(org.junit.Test)

Aggregations

MessageClientExt (org.apache.rocketmq.common.message.MessageClientExt)6 MessageExt (org.apache.rocketmq.common.message.MessageExt)4 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 InetSocketAddress (java.net.InetSocketAddress)2 HashSet (java.util.HashSet)2 ConsumeConcurrentlyContext (org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext)2 ConsumeConcurrentlyStatus (org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus)2 MessageListenerConcurrently (org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently)2 MQBrokerException (org.apache.rocketmq.client.exception.MQBrokerException)2 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 CommunicationMode (org.apache.rocketmq.client.impl.CommunicationMode)2 FindBrokerResult (org.apache.rocketmq.client.impl.FindBrokerResult)2 DefaultMQPushConsumerImpl (org.apache.rocketmq.client.impl.consumer.DefaultMQPushConsumerImpl)2 PullAPIWrapper (org.apache.rocketmq.client.impl.consumer.PullAPIWrapper)2 RebalancePushImpl (org.apache.rocketmq.client.impl.consumer.RebalancePushImpl)2 MQClientInstance (org.apache.rocketmq.client.impl.factory.MQClientInstance)2 MessageQueue (org.apache.rocketmq.common.message.MessageQueue)2 PullMessageRequestHeader (org.apache.rocketmq.common.protocol.header.PullMessageRequestHeader)2 RemotingException (org.apache.rocketmq.remoting.exception.RemotingException)2