Commit 27ce763c authored by mriedl's avatar mriedl
Browse files

retrying connection, movied to subscription part

parent bc6edd9f
Pipeline #14906 passed with stages
in 4 minutes and 12 seconds
......@@ -105,18 +105,19 @@ public class CommunicationService {
}
private void subscribeWithRetries(String topicName, ActiveMQListener mqListener) {
int retriesCount = properties.getActiveMqRestartCount();
while (retriesCount > 0) {
int retriesLeft = properties.getActiveMqRestartCount();
while (retriesLeft > 0) {
try {
Objects.requireNonNull(brokerClients.computeIfAbsent(topicName, client -> getNewClient()))
.subscribe(null, topicName, mqListener);
break;
} catch (JMSException e) {
e.printStackTrace();
log.warn("Connection failed, retrying in: {}", properties.getActiveMqRestartInterval());
log.warn("Connection failed, retrying in: {} milliseconds, retries left: {}",
properties.getActiveMqRestartInterval(), retriesLeft);
try {
Thread.sleep(properties.getActiveMqRestartInterval());
retriesCount--;
retriesLeft--;
} catch (InterruptedException iex) {
iex.printStackTrace();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment