mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
CLOUDSTACK-6365: support virtual host and ssl in rabbitMQ event bus
with this fix, virtual host on the AMQP server can be specified. Also SSL can be used for connection between management server and AMQP servers.
This commit is contained in:
parent
b5a93751e2
commit
bc17f17776
@ -60,6 +60,18 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
|
|||||||
private static String username;
|
private static String username;
|
||||||
private static String password;
|
private static String password;
|
||||||
|
|
||||||
|
public static void setVirtualHost(String virtualHost) {
|
||||||
|
RabbitMQEventBus.virtualHost = virtualHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String virtualHost;
|
||||||
|
|
||||||
|
public static void setUseSsl(String useSsl) {
|
||||||
|
RabbitMQEventBus.useSsl = useSsl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String useSsl;
|
||||||
|
|
||||||
// AMQP exchange name where all CloudStack events will be published
|
// AMQP exchange name where all CloudStack events will be published
|
||||||
private static String amqpExchangeName;
|
private static String amqpExchangeName;
|
||||||
|
|
||||||
@ -104,6 +116,12 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
|
|||||||
throw new ConfigurationException("Unable to get the port details of AMQP server");
|
throw new ConfigurationException("Unable to get the port details of AMQP server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useSsl != null && !useSsl.isEmpty()) {
|
||||||
|
if (!useSsl.equalsIgnoreCase("true") && !useSsl.equalsIgnoreCase("false")) {
|
||||||
|
throw new ConfigurationException("Invalid configuration parameter for 'ssl'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (retryInterval == null) {
|
if (retryInterval == null) {
|
||||||
retryInterval = 10000;// default to 10s to try out reconnect
|
retryInterval = 10000;// default to 10s to try out reconnect
|
||||||
}
|
}
|
||||||
@ -345,9 +363,18 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
|
|||||||
ConnectionFactory factory = new ConnectionFactory();
|
ConnectionFactory factory = new ConnectionFactory();
|
||||||
factory.setUsername(username);
|
factory.setUsername(username);
|
||||||
factory.setPassword(password);
|
factory.setPassword(password);
|
||||||
factory.setVirtualHost("/");
|
|
||||||
factory.setHost(amqpHost);
|
factory.setHost(amqpHost);
|
||||||
factory.setPort(port);
|
factory.setPort(port);
|
||||||
|
|
||||||
|
if (virtualHost != null && !virtualHost.isEmpty()) {
|
||||||
|
factory.setVirtualHost(virtualHost);
|
||||||
|
} else {
|
||||||
|
factory.setVirtualHost("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useSsl != null && !useSsl.isEmpty() && useSsl.equalsIgnoreCase("true")) {
|
||||||
|
factory.useSslProtocol();
|
||||||
|
}
|
||||||
Connection connection = factory.newConnection();
|
Connection connection = factory.newConnection();
|
||||||
connection.addShutdownListener(disconnectHandler);
|
connection.addShutdownListener(disconnectHandler);
|
||||||
s_connection = connection;
|
s_connection = connection;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user