Skip to content

Commit

Permalink
fix: fix the fifo message of tag and order test
Browse files Browse the repository at this point in the history
Signed-off-by: wangxye <[email protected]>
  • Loading branch information
wangxye committed Nov 13, 2023
1 parent 60d8985 commit 87b3a59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
import org.apache.rocketmq.util.NameUtils;
import org.apache.rocketmq.util.TestUtils;
import org.apache.rocketmq.util.VerifyUtils;
import org.awaitility.Awaitility;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -102,6 +104,7 @@ public void testSndTagATagB_SubTagATagB() {
// simpleConsumer = ConsumerFactory.getRMQSimpleConsumer(account, topic, groupId, new FilterExpression(receiveTag), Duration.ofSeconds(10));
// VerifyUtils.tryReceiveOnce(simpleConsumer.getSimpleConsumer());
producer = ProducerFactory.getRMQProducer(account, topic);
TestUtils.waitForSeconds(1);
Assertions.assertNotNull(producer);
producer.send(topic, sendTagA, SEND_NUM);
producer.send(topic, sendTagB, SEND_NUM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class SimpleOrderParamTest extends BaseOperate {
private String tag;
private String groupId;
private final static int SEND_NUM = 20;
static final String PROPERTY_SHARDING_KEY = "__SHARDINGKEY";

@BeforeEach
public void setUp() {
Expand All @@ -82,10 +83,11 @@ public void testFIFO_simple_receive_nack() {
VerifyUtils.tryReceiveOnce(consumer);
RMQNormalProducer producer = ProducerFactory.getRMQProducer(account, topic);
Assertions.assertNotNull(producer, "Get Producer failed");

String orderId = RandomUtils.getStringByUUID();
String messageGroup = RandomUtils.getStringByUUID();
for (int i = 0; i < SEND_NUM; i++) {
Message message = MessageFactory.buildOrderMessage(topic, tag, String.valueOf(i), messageGroup);
message.getProperties().put(PROPERTY_SHARDING_KEY, orderId);
producer.send(message);
}
TestUtils.waitForSeconds(1);
Expand Down Expand Up @@ -193,14 +195,15 @@ public void testFIFO_simple_receive_multi_nack() {
String groupId = getOrderlyGroupId(methodName);

SimpleConsumer consumer = ConsumerFactory.getSimpleConsumer(account, topic, groupId, new FilterExpression(tag), Duration.ofSeconds(10));
VerifyUtils.tryReceiveOnce(consumer);
// VerifyUtils.tryReceiveOnce(consumer);
RMQNormalProducer producer = ProducerFactory.getRMQProducer(account, topic);
Assertions.assertNotNull(producer, "Get Producer failed");

String orderId = RandomUtils.getStringByUUID();
String messageGroup = RandomUtils.getStringByUUID();
for (int i = 0; i < SEND_NUM; i++) {
System.out.printf("Producer send message %s%n", i);
Message message = MessageFactory.buildOrderMessage(topic, tag, String.valueOf(i), messageGroup);
message.getProperties().put(PROPERTY_SHARDING_KEY, orderId);
producer.send(message);
}
TestUtils.waitForSeconds(1);
Expand Down

0 comments on commit 87b3a59

Please sign in to comment.