Skip to content

Commit

Permalink
ARTEMIS-5218 StompHandler HeartBeat restarted after being stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic authored and jbertram committed Dec 17, 2024
1 parent 5c1ecea commit 54f9993
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ private class HeartBeater extends ActiveMQScheduledComponent {

private static final int MIN_SERVER_PING = 500;

private boolean previouslyStopped = false;

long serverPingPeriod = 0;
long clientPingResponse;
AtomicLong lastPingTimestamp = new AtomicLong(0);
Expand Down Expand Up @@ -321,7 +323,14 @@ private HeartBeater(ScheduledExecutorService scheduledExecutorService,

public void shutdown() {
this.stop();
previouslyStopped = true;
}

@Override
public void start() {
if (!previouslyStopped) {
super.start();
}
}

public void pinged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public static void assertFalse(String failureMessage, Condition condition, final
assertTrue(failureMessage, () -> !condition.isSatisfied(), duration, SLEEP_MILLIS);
}

public static void assertFalse(Supplier<String> failureMessage, Condition condition, final long duration, final long sleep) {
assertTrue(failureMessage, () -> !condition.isSatisfied(), duration, sleep);
}

public static void assertFalse(Condition condition, final long duration, final long sleep) {
assertTrue(DEFAULT_FAILURE_MESSAGE, () -> !condition.isSatisfied(), duration, sleep);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2255,6 +2255,8 @@ public void testHeartBeat4() throws Exception {
subFrame.addHeader("destination", getTopicPrefix() + getTopicName());
subFrame.addHeader("id", "0");

Wait.assertTrue(() -> "HeartBeater is not running!! -> " + System.identityHashCode(stompFrameHandler.getHeartBeater()), () -> stompFrameHandler.getHeartBeater().isStarted(), 5000, 100);

ClientStompFrame f = conn.sendFrame(subFrame);
f = conn.sendFrame(subFrame);

Expand All @@ -2269,7 +2271,7 @@ public void testHeartBeat4() throws Exception {

Wait.assertEquals(0, () -> server.getRemotingService().getConnections().size());

Wait.assertFalse("HeartBeater is still running!!", () -> stompFrameHandler.getHeartBeater().isStarted());
Wait.assertFalse(() -> "HeartBeater is still running!! -> " + System.identityHashCode(stompFrameHandler.getHeartBeater()), () -> stompFrameHandler.getHeartBeater().isStarted(), 5000, 100);
}


Expand Down

0 comments on commit 54f9993

Please sign in to comment.