RabbitMQ log enhancement (#4100)

This commit is contained in:
Gabriel Beims Bräscher 2020-06-02 05:13:23 -03:00 committed by GitHub
parent 27e7637b02
commit ec60e820f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,11 +21,14 @@ package org.apache.cloudstack.mom.rabbitmq;
import java.io.IOException; import java.io.IOException;
import java.net.ConnectException; import java.net.ConnectException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeoutException;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
@ -358,8 +361,8 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
if (s_connection == null) { if (s_connection == null) {
try { try {
return createConnection(); return createConnection();
} catch (Exception e) { } catch (KeyManagementException | NoSuchAlgorithmException | IOException | TimeoutException e) {
s_logger.error("Failed to create a connection to AMQP server due to " + e.getMessage()); s_logger.error(String.format("Failed to create a connection to AMQP server [AMQP host:%s, port:%d] due to: %s", amqpHost, port, e));
throw e; throw e;
} }
} else { } else {
@ -367,8 +370,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
} }
} }
private synchronized Connection createConnection() throws Exception { private synchronized Connection createConnection() throws KeyManagementException, NoSuchAlgorithmException, IOException, TimeoutException {
try {
ConnectionFactory factory = new ConnectionFactory(); ConnectionFactory factory = new ConnectionFactory();
factory.setUsername(username); factory.setUsername(username);
factory.setPassword(password); factory.setPassword(password);
@ -389,9 +391,6 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
connection.addBlockedListener(blockedConnectionHandler); connection.addBlockedListener(blockedConnectionHandler);
s_connection = connection; s_connection = connection;
return s_connection; return s_connection;
} catch (Exception e) {
throw e;
}
} }
private synchronized void closeConnection() { private synchronized void closeConnection() {