Skip to content

Commit

Permalink
ARTEMIS-5173 Improve reliability of ReplicaTXCheckTest
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic committed Nov 21, 2024
1 parent 72dae9e commit f260c40
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.jms.TransactionRolledBackException;
import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.HashSet;
Expand Down Expand Up @@ -230,16 +231,23 @@ void testTXCheck(String protocol, boolean killTarget, boolean useStop) throws Ex

HashSet<Integer> received = new HashSet<>();
int rec = 0;
while (true) {
TextMessage message = (TextMessage) subscription.receive(100);
if (message == null) {
logger.info("Received {} messages", rec);
for (long timeout = System.currentTimeMillis() + 60_000; System.currentTimeMillis() < timeout;) {
rec = 0;
while (true) {
TextMessage message = (TextMessage) subscription.receive(100);
if (message == null) {
logger.info("Received {} messages", rec);
break;
}
received.add(message.getIntProperty("i"));
rec++;
}
try {
targetSession.commit();
break;
} catch (TransactionRolledBackException ok) {
}
received.add(message.getIntProperty("i"));
rec++;
}
targetSession.commit();

for (i = 0; i < NUMBER_OF_MESSAGES; i++) {
assertTrue(received.contains(i));
Expand Down

0 comments on commit f260c40

Please sign in to comment.