Remove events from beforeStartupEventsQueue after fire()

The plugin was removing the event before firing it from the
beforeStartupEventsQueue. This could have caused a message
loss in case the configuration was changed before firing the event.

Now after the plugin is fully loaded each event is
removed from the the in-memory queue after being fired.

Follow up of change 391054.

Change-Id: I4ccef01f42dc11c5df84ca8dfa231e6e895d8a2d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
index 8fb6b0d..ac17fac 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
@@ -764,7 +764,7 @@
   private void fireBeforeStartupEvents() {
     Set<String> eventsReplayed = new HashSet<>();
     ReferenceBatchUpdatedEvent event;
-    while ((event = beforeStartupEventsQueue.poll()) != null) {
+    while ((event = beforeStartupEventsQueue.peek()) != null) {
       String eventKey =
           String.format(
               "%s:%s",
@@ -777,6 +777,7 @@
         fire(event);
         eventsReplayed.add(eventKey);
       }
+      beforeStartupEventsQueue.remove(event);
     }
   }