Skip to content
Merged
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 @@ -1013,8 +1013,8 @@ public void testSubscriptionQueueRoutingType() throws Exception {
@Test
@Timeout(DEFAULT_TIMEOUT_SEC)
public void testConcurrentReconnectAndResubscribe() throws Exception {
final int clientCount = 100;
final int subsPerClient = 100;
final int clientCount = 50;
final int subsPerClient = 50;
final int resubscribeCount = 10;
AtomicBoolean failed = new AtomicBoolean(false);
ExecutorService executorService = Executors.newFixedThreadPool(clientCount);
Expand All @@ -1039,9 +1039,9 @@ public void testConcurrentReconnectAndResubscribe() throws Exception {
}

for (int i = 0; i < resubscribeCount; i++) {
client.connect(options);
connectSafely(client);
client.subscribe(subs);
client.disconnect();
disconnectSafely(client);
}
client.close();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,37 @@ private DuplicateIDCache getCache(String clientId, PacketIdCache.TYPE type) {
}
}

protected static void reconnectSafely(MqttClient subscriber) throws Exception {
protected static void reconnectSafely(MqttClient client) throws Exception {
Wait.waitFor(() -> {
try {
subscriber.reconnect();
client.reconnect();
return true;
} catch (MqttException e) {
return false;
}
});
}, 2000, 10);
}

protected static void connectSafely(MqttClient client) throws Exception {
Wait.waitFor(() -> {
try {
client.connect();
return true;
} catch (MqttException e) {
return false;
}
}, 2000, 10);
}

protected static void disconnectSafely(MqttClient client) throws Exception {
Wait.waitFor(() -> {
try {
client.disconnect();
return true;
} catch (MqttException e) {
return false;
}
}, 2000, 10);
}

/*
Expand Down
Loading