Skip to content

Commit ec60e82

Browse files
RabbitMQ log enhancement (#4100)
1 parent 27e7637 commit ec60e82

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

plugins/event-bus/rabbitmq/src/main/java/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121

2222
import java.io.IOException;
2323
import java.net.ConnectException;
24+
import java.security.KeyManagementException;
25+
import java.security.NoSuchAlgorithmException;
2426
import java.util.Map;
2527
import java.util.UUID;
2628
import java.util.concurrent.ConcurrentHashMap;
2729
import java.util.concurrent.ExecutorService;
2830
import java.util.concurrent.Executors;
31+
import java.util.concurrent.TimeoutException;
2932

3033
import javax.naming.ConfigurationException;
3134

@@ -358,17 +361,16 @@ private synchronized Connection getConnection() throws Exception {
358361
if (s_connection == null) {
359362
try {
360363
return createConnection();
361-
} catch (Exception e) {
362-
s_logger.error("Failed to create a connection to AMQP server due to " + e.getMessage());
364+
} catch (KeyManagementException | NoSuchAlgorithmException | IOException | TimeoutException e) {
365+
s_logger.error(String.format("Failed to create a connection to AMQP server [AMQP host:%s, port:%d] due to: %s", amqpHost, port, e));
363366
throw e;
364367
}
365368
} else {
366369
return s_connection;
367370
}
368371
}
369372

370-
private synchronized Connection createConnection() throws Exception {
371-
try {
373+
private synchronized Connection createConnection() throws KeyManagementException, NoSuchAlgorithmException, IOException, TimeoutException {
372374
ConnectionFactory factory = new ConnectionFactory();
373375
factory.setUsername(username);
374376
factory.setPassword(password);
@@ -389,9 +391,6 @@ private synchronized Connection createConnection() throws Exception {
389391
connection.addBlockedListener(blockedConnectionHandler);
390392
s_connection = connection;
391393
return s_connection;
392-
} catch (Exception e) {
393-
throw e;
394-
}
395394
}
396395

397396
private synchronized void closeConnection() {

0 commit comments

Comments
 (0)