Set default value to queue.name
diff --git a/README.md b/README.md
index a84d237..56a9bf0 100644
--- a/README.md
+++ b/README.md
@@ -14,18 +14,6 @@
Now available for Gerrit 2.8 only, but you may use this on another version of Gerrit if you modify `Gerrit-ApiVersion` in pom.xml.
-Minimum configuration
-----------------------
-
-In `rabbitmq.config`
-
-```
-[amqp]
- uri = amqp://localhost
-```
-
-You should declare exchange named `gerrit.publish` beforehand.
-
License
---------------------
diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/AMQPSession.java b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/AMQPSession.java
index 0eeea5f..b28dabd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/AMQPSession.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/AMQPSession.java
@@ -81,7 +81,7 @@
Channel ch = connection.createChannel();
LOGGER.info("Channel is opened.");
if (properties.getBoolean(Keys.QUEUE_DECLARE)) {
- LOGGER.info("Declare Queue...");
+ LOGGER.info("Declare queue...");
if (StringUtils.isNotEmpty(properties.getString(Keys.QUEUE_NAME))) {
LOGGER.info("Declare queue: " + properties.getString(Keys.QUEUE_NAME));
ch.queueDeclare(properties.getString(Keys.QUEUE_NAME),
@@ -91,15 +91,19 @@
}
if (properties.getBoolean(Keys.EXCHANGE_DECLARE)) {
- LOGGER.info("Declare exchange: " + properties.getString(Keys.EXCHANGE_NAME));
- ch.exchangeDeclare(properties.getString(Keys.EXCHANGE_NAME),
- properties.getString(Keys.EXCHANGE_TYPE),
- properties.getBoolean(Keys.EXCHANGE_DURABLE),
- properties.getBoolean(Keys.EXCHANGE_AUTODELETE), null);
+ LOGGER.info("Declare exchange...");
+ if (StringUtils.isNotEmpty(properties.getString(Keys.EXCHANGE_NAME))) {
+ LOGGER.info("Declare exchange: " + properties.getString(Keys.EXCHANGE_NAME));
+ ch.exchangeDeclare(properties.getString(Keys.EXCHANGE_NAME),
+ properties.getString(Keys.EXCHANGE_TYPE),
+ properties.getBoolean(Keys.EXCHANGE_DURABLE),
+ properties.getBoolean(Keys.EXCHANGE_AUTODELETE), null);
+ }
}
if (properties.getBoolean(Keys.BIND_STARTUP)) {
- if (StringUtils.isNotEmpty(properties.getString(Keys.QUEUE_NAME))) {
+ if (StringUtils.isNotEmpty(properties.getString(Keys.QUEUE_NAME)) &&
+ StringUtils.isNotEmpty(properties.getString(Keys.EXCHANGE_NAME))) {
LOGGER.info("Bind exchange and queue with key: " + properties.getString(Keys.BIND_ROUTINGKEY));
ch.queueBind(properties.getString(Keys.QUEUE_NAME),
properties.getString(Keys.EXCHANGE_NAME),
diff --git a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/Keys.java b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/Keys.java
index b45e25b..43eb3b6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/Keys.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/rabbitmq/Keys.java
@@ -18,7 +18,7 @@
AMQP_URI("amqp.uri", null, "amqp://localhost"),
AMQP_USERNAME("amqp.username", null, "guest"),
AMQP_PASSWORD("amqp.password", null, "guest"),
- QUEUE_NAME("queue.name", null, ""),
+ QUEUE_NAME("queue.name", null, "gerrit.events"),
QUEUE_DECLARE("queue.declare", null, false),
QUEUE_DURABLE("queue.durable", null, true),
QUEUE_AUTODELETE("queue.autoDelete", null, false),
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index f8a11ee..5cae16c 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -50,7 +50,6 @@
queue.declare
: true if you want to declare queue on startup.
- Also need to specify `queue.name`.
queue.durable
: true if you want to declare a drable queue.
@@ -122,19 +121,21 @@
You can change the below values by specifying them in `rabbitmq.config`.
+**Bold** is String value.
+
|name | value
|:-------------------|:------------------
-|amqp.uri | amqp://localhost
-|amqp.username | guest
-|amqp.password | guest
-|queue.name | *Empty*
+|amqp.uri | **amqp://localhost**
+|amqp.username | **guest**
+|amqp.password | **guest**
+|queue.name | **gerrit.events**
|queue.declare | false
|queue.durable | true
|queue.autoDelete | false
|queue.exclusive | false
-|exchange.name | gerrit.publish
+|exchange.name | **gerrit.publish**
|exchange.declare | false
-|exchange.type | fanout
+|exchange.type | **fanout**
|exchange.durable | false
|exchange.autoDelete | false
|bind.startUp | false
@@ -144,6 +145,6 @@
|message.routingKey | *Empty*
|gerrit.name | *Empty*
|gerrit.hostname | *Empty*
-|gerrit.scheme | ssh
+|gerrit.scheme | **ssh**
|gerrit.port | 29418
|monitor.interval | 15000