Added virtual host support for RabbitMQ (#2877)

This commit is contained in:
Callum Seabrook 2021-02-05 11:38:13 +00:00 committed by GitHub
parent a8dfd38fe6
commit d8aefd23d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 2 deletions

View File

@ -253,6 +253,7 @@ redis:
rabbitmq:
enabled: false
address: localhost
vhost: '/'
username: 'guest'
password: 'guest'

View File

@ -251,6 +251,7 @@ redis:
rabbitmq:
enabled: false
address: localhost
vhost: '/'
username: 'guest'
password: 'guest'

View File

@ -629,6 +629,11 @@ public final class ConfigKeys {
*/
public static final ConfigKey<String> RABBITMQ_ADDRESS = notReloadable(stringKey("rabbitmq.address", null));
/**
* The virtual host to be used by the rabbitmq server
*/
public static final ConfigKey<String> RABBITMQ_VIRTUAL_HOST = notReloadable(stringKey("rabbitmq.vhost", "/"));
/**
* The username in use by the rabbitmq server
*/

View File

@ -162,10 +162,11 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
LuckPermsConfiguration config = getPlugin().getConfiguration();
String address = config.get(ConfigKeys.RABBITMQ_ADDRESS);
String virtualHost = config.get(ConfigKeys.RABBITMQ_VIRTUAL_HOST);
String username = config.get(ConfigKeys.RABBITMQ_USERNAME);
String password = config.get(ConfigKeys.RABBITMQ_PASSWORD);
rabbitmq.init(address, username, password);
rabbitmq.init(address, virtualHost, username, password);
return rabbitmq;
}
}

View File

@ -65,7 +65,7 @@ public class RabbitMQMessenger implements Messenger {
this.consumer = consumer;
}
public void init(String address, String username, String password) {
public void init(String address, String virtualHost, String username, String password) {
String[] addressSplit = address.split(":");
String host = addressSplit[0];
int port = addressSplit.length > 1 ? Integer.parseInt(addressSplit[1]) : DEFAULT_PORT;
@ -73,6 +73,7 @@ public class RabbitMQMessenger implements Messenger {
this.connectionFactory = new ConnectionFactory();
this.connectionFactory.setHost(host);
this.connectionFactory.setPort(port);
this.connectionFactory.setVirtualHost(virtualHost);
this.connectionFactory.setUsername(username);
this.connectionFactory.setPassword(password);

View File

@ -257,6 +257,7 @@ redis {
rabbitmq {
enabled = false
address = "localhost"
vhost = "/"
username = "guest"
password = "guest"
}

View File

@ -248,6 +248,7 @@ redis:
rabbitmq:
enabled: false
address: localhost
vhost: '/'
username: 'guest'
password: 'guest'

View File

@ -257,6 +257,7 @@ redis {
rabbitmq {
enabled = false
address = "localhost"
vhost = "/"
username = "guest"
password = "guest"
}

View File

@ -242,6 +242,7 @@ redis:
rabbitmq:
enabled: false
address: localhost
vhost: '/'
username: 'guest'
password: 'guest'