Java Code Examples for org.apache.rocketmq.test.factory.TagMessage#getMixedTagMessages()

The following examples show how to use org.apache.rocketmq.test.factory.TagMessage#getMixedTagMessages() . 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: TagMessageWithMulConsumerIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 2
Source File: TagMessageWithMulConsumerIT.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListner());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListner());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags),
        consumeTime);
    consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
 
Example 3
Source File: TagMessageWithMulConsumerIT.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListner());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListner());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 4
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListner());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListner());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags),
        consumeTime);
    consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
 
Example 5
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListner());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListner());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 6
Source File: TagMessageWithMulConsumerIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
 
Example 7
Source File: TagMessageWithMulConsumerIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 8
Source File: TagMessageWithMulConsumerIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 9
Source File: TagMessageWithMulConsumerIT.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListner());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListner());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 10
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
 
Example 11
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 12
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
 
Example 13
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendMessagesWithTwoTag() {
    String tags[] = {"jueyin1", "jueyin2"};
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, tags[0],
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, tags[1],
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[1]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[1]));
}
 
Example 14
Source File: TagMessageWithMulConsumerIT.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testTwoConsumerOneMatchOneOtherMatchAll() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    int msgSize = 10;

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    RMQNormalConsumer consumerTag1 = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerTag2 = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());

    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * tags.length,
        producer.getAllUndupMsgBody().size());

    consumerTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags),
        consumeTime);
    consumerTag2.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerTag2.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
}
 
Example 15
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Test
public void testSubKindsOf() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    String sub3 = tags[0];
    String sub4 = "*";
    int msgSize = 10;

    RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4,
        new RMQNormalListener());

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());

    consumerSubTwoMatchAll.getListener()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
    consumerSubTwoMachieOne.getListener()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
    consumerSubTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerSubAll.getListener().waitForMessageConsume(
        MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMatchAll.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMachieOne.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubAll.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag,
            tagMessage.getAllTagMessageBody()));
}
 
Example 16
Source File: TagMessageWithMulConsumerIT.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Test
public void testSubKindsOf() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    String sub3 = tags[0];
    String sub4 = "*";
    int msgSize = 10;

    RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4,
        new RMQNormalListner());

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());

    consumerSubTwoMatchAll.getListner()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
    consumerSubTwoMachieOne.getListner()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
    consumerSubTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerSubAll.getListner().waitForMessageConsume(
        MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMatchAll.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMachieOne.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubAll.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag,
            tagMessage.getAllTagMessageBody()));
}
 
Example 17
Source File: TagMessageWithMulConsumerIT.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
@Test
public void testSubKindsOf() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    String sub3 = tags[0];
    String sub4 = "*";
    int msgSize = 10;

    RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4,
        new RMQNormalListner());

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());

    consumerSubTwoMatchAll.getListner()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
    consumerSubTwoMachieOne.getListner()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
    consumerSubTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerSubAll.getListner().waitForMessageConsume(
        MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMatchAll.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMachieOne.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubAll.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag,
            tagMessage.getAllTagMessageBody()));
}
 
Example 18
Source File: TagMessageWithMulConsumerIT.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Test
public void testSubKindsOf() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    String sub3 = tags[0];
    String sub4 = "*";
    int msgSize = 10;

    RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4,
        new RMQNormalListener());

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());

    consumerSubTwoMatchAll.getListener()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
    consumerSubTwoMachieOne.getListener()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
    consumerSubTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerSubAll.getListener().waitForMessageConsume(
        MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMatchAll.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMachieOne.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubAll.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag,
            tagMessage.getAllTagMessageBody()));
}
 
Example 19
Source File: TagMessageWithMulConsumerIT.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
@Test
public void testSubKindsOf() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    String sub3 = tags[0];
    String sub4 = "*";
    int msgSize = 10;

    RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3,
        new RMQNormalListner());
    RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4,
        new RMQNormalListner());

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());

    consumerSubTwoMatchAll.getListner()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
    consumerSubTwoMachieOne.getListner()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
    consumerSubTag1.getListner().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerSubAll.getListner().waitForMessageConsume(
        MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMatchAll.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMachieOne.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTag1.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubAll.getListner().getAllMsgBody()))
        .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag,
            tagMessage.getAllTagMessageBody()));
}
 
Example 20
Source File: TagMessageWithMulConsumerIT.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
@Test
public void testSubKindsOf() {
    String tags[] = {"jueyin1", "jueyin2"};
    String sub1 = String.format("%s||%s", tags[0], tags[1]);
    String sub2 = String.format("%s|| noExist", tags[0]);
    String sub3 = tags[0];
    String sub4 = "*";
    int msgSize = 10;

    RMQNormalConsumer consumerSubTwoMatchAll = getConsumer(nsAddr, topic, sub1,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubTwoMachieOne = getConsumer(nsAddr, topic, sub2,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubTag1 = getConsumer(nsAddr, topic, sub3,
        new RMQNormalListener());
    RMQNormalConsumer consumerSubAll = getConsumer(nsAddr, topic, sub4,
        new RMQNormalListener());

    producer.send(msgSize);
    Assert.assertEquals("Not all are sent", msgSize, producer.getAllUndupMsgBody().size());
    Collection<Object> msgsWithNoTag = producer.getMsgBodysCopy();

    TagMessage tagMessage = new TagMessage(tags, topic, msgSize);
    List<Object> tagMsgs = tagMessage.getMixedTagMessages();
    producer.send(tagMsgs);
    Assert.assertEquals("Not all are sent", msgSize * 3, producer.getAllUndupMsgBody().size());

    consumerSubTwoMatchAll.getListener()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags), consumeTime);
    consumerSubTwoMachieOne.getListener()
        .waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]), consumeTime);
    consumerSubTag1.getListener().waitForMessageConsume(tagMessage.getMessageBodyByTag(tags[0]),
        consumeTime);
    consumerSubAll.getListener().waitForMessageConsume(
        MQMessageFactory.getMessage(msgsWithNoTag, tagMessage.getAllTagMessageBody()),
        consumeTime);

    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMatchAll.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getAllTagMessageBody());
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTwoMachieOne.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubTag1.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(tagMessage.getMessageBodyByTag(tags[0]));
    assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
        consumerSubAll.getListener().getAllMsgBody()))
        .containsExactlyElementsIn(MQMessageFactory.getMessage(msgsWithNoTag,
            tagMessage.getAllTagMessageBody()));
}