Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public class BrokerConfig extends BrokerIdentity {
private boolean initPopOffsetByCheckMsgInMem = true;
// read message from pop retry topic v1, for the compatibility, will be removed in the future version
private boolean retrieveMessageFromPopRetryTopicV1 = true;
private boolean enableRetryTopicV2 = false;
private boolean enableRetryTopicV2 = true;
private int popFromRetryProbability = 20;
// pop retry probability for priority mode
private int popFromRetryProbabilityForPriority = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,27 @@ public void testIsPopRetryTopicV2() {
String popRetryTopicV1 = KeyBuilder.buildPopRetryTopicV1(topic, group);
assertThat(KeyBuilder.isPopRetryTopicV2(popRetryTopicV1)).isEqualTo(false);
}

@Test
public void testV1CollisionExample() {
// Demonstrates the V1 naming collision: different (group, topic) pairs produce the same retry topic
// group="A_B" topic="C" vs group="A" topic="B_C" both produce %RETRY%A_B_C
String collision1 = KeyBuilder.buildPopRetryTopicV1("C", "A_B");
String collision2 = KeyBuilder.buildPopRetryTopicV1("B_C", "A");
assertThat(collision1).isEqualTo(collision2); // both are %RETRY%A_B_C
}

@Test
public void testV2NoCollision() {
// V2 uses '+' separator which is not allowed in topic/group names, so no collision
String v2a = KeyBuilder.buildPopRetryTopicV2("C", "A_B");
String v2b = KeyBuilder.buildPopRetryTopicV2("B_C", "A");
assertThat(v2a).isNotEqualTo(v2b); // %RETRY%A_B+C vs %RETRY%A+B_C
}

@Test
public void testDefaultEnableRetryTopicV2IsTrue() {
BrokerConfig config = new BrokerConfig();
assertThat(config.isEnableRetryTopicV2()).isTrue();
}
}
Loading