You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/01/25 03:55:17 UTC

[01/10] james-project git commit: MAILBOX-374 Write a test about error recovery

Repository: james-project
Updated Branches:
  refs/heads/master 0e9cd67e1 -> df5d678cd


MAILBOX-374 Write a test about error recovery


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c47b846b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c47b846b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c47b846b

Branch: refs/heads/master
Commit: c47b846bc607465f02eae4bd39c6ed8c1d930fbb
Parents: 0e9cd67
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 13:23:27 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:31:33 2019 +0700

----------------------------------------------------------------------
 .../james/backend/rabbitmq/DockerRabbitMQ.java  |  8 +++
 .../mailbox/events/EventBusTestFixture.java     |  1 +
 .../mailbox/events/RabbitMQEventBusTest.java    | 76 ++++++++++++++++++++
 3 files changed, 85 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c47b846b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
index 81567c7..0d32047 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
@@ -236,6 +236,14 @@ public class DockerRabbitMQ {
         }
     }
 
+    public void pause() {
+        DockerClientFactory.instance().client().pauseContainerCmd(container.getContainerId()).exec();
+    }
+
+    public void unpause() {
+        DockerClientFactory.instance().client().unpauseContainerCmd(container.getContainerId()).exec();
+    }
+
     public RabbitMQConnectionFactory createRabbitConnectionFactory() throws URISyntaxException {
         RabbitMQConfiguration rabbitMQConfiguration = RabbitMQConfiguration.builder()
             .amqpUri(amqpUri())

http://git-wip-us.apache.org/repos/asf/james-project/blob/c47b846b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
index d11571c..d2f3097 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
@@ -85,6 +85,7 @@ public interface EventBusTestFixture {
     MailboxListener.MailboxEvent EVENT_2 = new MailboxListener.MailboxAdded(SESSION_ID, USER, MAILBOX_PATH, TEST_ID, EVENT_ID_2);
 
     int ONE_SECOND = 1000;
+    int THIRTY_SECONDS = 30 * ONE_SECOND;
     int FIVE_HUNDRED_MS = 500;
     MailboxId ID_1 = TEST_ID;
     MailboxId ID_2 = TestId.of(24);

http://git-wip-us.apache.org/repos/asf/james-project/blob/c47b846b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
index 69204ad..2137610 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
@@ -32,6 +32,7 @@ import static org.apache.james.mailbox.events.EventBusTestFixture.GroupA;
 import static org.apache.james.mailbox.events.EventBusTestFixture.KEY_1;
 import static org.apache.james.mailbox.events.EventBusTestFixture.MailboxListenerCountingSuccessfulExecution;
 import static org.apache.james.mailbox.events.EventBusTestFixture.NO_KEYS;
+import static org.apache.james.mailbox.events.EventBusTestFixture.THIRTY_SECONDS;
 import static org.apache.james.mailbox.events.EventBusTestFixture.WAIT_CONDITION;
 import static org.apache.james.mailbox.events.EventBusTestFixture.newListener;
 import static org.apache.james.mailbox.events.GroupRegistration.WorkQueueName.MAILBOX_EVENT_WORK_QUEUE_PREFIX;
@@ -39,10 +40,14 @@ import static org.apache.james.mailbox.events.RabbitMQEventBus.MAILBOX_EVENT;
 import static org.apache.james.mailbox.events.RabbitMQEventBus.MAILBOX_EVENT_EXCHANGE_NAME;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.after;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import java.nio.charset.StandardCharsets;
 import java.time.Duration;
@@ -73,6 +78,7 @@ import reactor.rabbitmq.BindingSpecification;
 import reactor.rabbitmq.ExchangeSpecification;
 import reactor.rabbitmq.QueueSpecification;
 import reactor.rabbitmq.RabbitFlux;
+import reactor.rabbitmq.RabbitFluxException;
 import reactor.rabbitmq.Receiver;
 import reactor.rabbitmq.ReceiverOptions;
 import reactor.rabbitmq.Sender;
@@ -301,6 +307,76 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
             }
 
             @Test
+            void dispatchShouldWorkAfterNetworkIssuesForOldRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+                eventBus.register(listener, GROUP_A);
+
+                rabbitMQExtension.getRabbitMQ().pause();
+
+                assertThatThrownBy(() -> eventBus.dispatch(EVENT, NO_KEYS).block())
+                    .isInstanceOf(RabbitFluxException.class);
+
+                rabbitMQExtension.getRabbitMQ().unpause();
+
+                eventBus.dispatch(EVENT, NO_KEYS).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
+            void dispatchShouldWorkAfterNetworkIssuesForNewRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+
+                rabbitMQExtension.getRabbitMQ().pause();
+
+                assertThatThrownBy(() -> eventBus.dispatch(EVENT, NO_KEYS).block())
+                    .isInstanceOf(RabbitFluxException.class);
+
+                rabbitMQExtension.getRabbitMQ().unpause();
+
+                eventBus.register(listener, GROUP_A);
+                eventBus.dispatch(EVENT, NO_KEYS).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
+            void dispatchShouldWorkAfterNetworkIssuesForOldKeyRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+                when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
+                eventBus.register(listener, KEY_1);
+
+                rabbitMQExtension.getRabbitMQ().pause();
+
+                assertThatThrownBy(() -> eventBus.dispatch(EVENT, NO_KEYS).block())
+                    .isInstanceOf(RabbitFluxException.class);
+
+                rabbitMQExtension.getRabbitMQ().unpause();
+
+                eventBus.dispatch(EVENT, KEY_1).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
+            void dispatchShouldWorkAfterNetworkIssuesForNewKeyRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+                when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
+
+                rabbitMQExtension.getRabbitMQ().pause();
+
+                assertThatThrownBy(() -> eventBus.dispatch(EVENT, NO_KEYS).block())
+                    .isInstanceOf(RabbitFluxException.class);
+
+                rabbitMQExtension.getRabbitMQ().unpause();
+
+                eventBus.register(listener, KEY_1);
+                eventBus.dispatch(EVENT, KEY_1).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
             void stopShouldNotDeleteEventBusExchange() {
                 eventBus.start();
                 eventBus.stop();


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[05/10] james-project git commit: MAILBOX-374 Specify unit for minDelays upon connection retries

Posted by bt...@apache.org.
MAILBOX-374 Specify unit for minDelays upon connection retries


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c1a2a95b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c1a2a95b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c1a2a95b

Branch: refs/heads/master
Commit: c1a2a95b7f1092025bc289adf89ee27d0ab36eb1
Parents: edf8530
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 14:17:19 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:33:25 2019 +0700

----------------------------------------------------------------------
 .../backend/rabbitmq/RabbitMQConfiguration.java | 25 ++++++++++----------
 .../rabbitmq/RabbitMQConnectionFactory.java     |  2 +-
 .../james/backend/rabbitmq/DockerRabbitMQ.java  |  2 +-
 .../rabbitmq/RabbitMQConfigurationTest.java     |  6 ++---
 .../rabbitmq/RabbitMQConnectionFactoryTest.java |  2 +-
 5 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c1a2a95b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConfiguration.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConfiguration.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConfiguration.java
index 8da712a..41b4dfc 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConfiguration.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConfiguration.java
@@ -103,14 +103,14 @@ public class RabbitMQConfiguration {
         private final URI managementUri;
         private final ManagementCredentials managementCredentials;
         private Optional<Integer> maxRetries;
-        private Optional<Integer> minDelay;
+        private Optional<Integer> minDelayInMs;
 
         private Builder(URI amqpUri, URI managementUri, ManagementCredentials managementCredentials) {
             this.amqpUri = amqpUri;
             this.managementUri = managementUri;
             this.managementCredentials = managementCredentials;
             this.maxRetries = Optional.empty();
-            this.minDelay = Optional.empty();
+            this.minDelayInMs = Optional.empty();
         }
 
         public Builder maxRetries(int maxRetries) {
@@ -118,8 +118,8 @@ public class RabbitMQConfiguration {
             return this;
         }
 
-        public Builder minDelay(int minDelay) {
-            this.minDelay = Optional.of(minDelay);
+        public Builder minDelayInMs(int minDelay) {
+            this.minDelayInMs = Optional.of(minDelay);
             return this;
         }
 
@@ -131,7 +131,7 @@ public class RabbitMQConfiguration {
                     managementUri,
                     managementCredentials,
                     maxRetries.orElse(DEFAULT_MAX_RETRIES),
-                    minDelay.orElse(DEFAULT_MIN_DELAY));
+                    minDelayInMs.orElse(DEFAULT_MIN_DELAY));
         }
     }
 
@@ -170,15 +170,16 @@ public class RabbitMQConfiguration {
     private final URI uri;
     private final URI managementUri;
     private final int maxRetries;
-    private final int minDelay;
+    private final int minDelayInMs;
+
     private final ManagementCredentials managementCredentials;
 
-    private RabbitMQConfiguration(URI uri, URI managementUri, ManagementCredentials managementCredentials, int maxRetries, int minDelay) {
+    private RabbitMQConfiguration(URI uri, URI managementUri, ManagementCredentials managementCredentials, int maxRetries, int minDelayInMs) {
         this.uri = uri;
         this.managementUri = managementUri;
         this.managementCredentials = managementCredentials;
         this.maxRetries = maxRetries;
-        this.minDelay = minDelay;
+        this.minDelayInMs = minDelayInMs;
     }
 
     public URI getUri() {
@@ -193,8 +194,8 @@ public class RabbitMQConfiguration {
         return maxRetries;
     }
 
-    public int getMinDelay() {
-        return minDelay;
+    public int getMinDelayInMs() {
+        return minDelayInMs;
     }
 
     public ManagementCredentials getManagementCredentials() {
@@ -209,7 +210,7 @@ public class RabbitMQConfiguration {
             return Objects.equals(this.uri, that.uri)
                 && Objects.equals(this.managementUri, that.managementUri)
                 && Objects.equals(this.maxRetries, that.maxRetries)
-                && Objects.equals(this.minDelay, that.minDelay)
+                && Objects.equals(this.minDelayInMs, that.minDelayInMs)
                 && Objects.equals(this.managementCredentials, that.managementCredentials);
         }
         return false;
@@ -217,6 +218,6 @@ public class RabbitMQConfiguration {
 
     @Override
     public final int hashCode() {
-        return Objects.hash(uri, managementUri, maxRetries, minDelay, managementCredentials);
+        return Objects.hash(uri, managementUri, maxRetries, minDelayInMs, managementCredentials);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c1a2a95b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
index c13b21b..ac469e4 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
@@ -77,7 +77,7 @@ public class RabbitMQConnectionFactory {
 
     public Mono<Connection> connectionMono() {
         return Mono.fromCallable(new ConnectionCallable(connectionFactory))
-            .retryBackoff(configuration.getMaxRetries(), Duration.ofMillis(configuration.getMinDelay()))
+            .retryBackoff(configuration.getMaxRetries(), Duration.ofMillis(configuration.getMinDelayInMs()))
             .publishOn(Schedulers.elastic());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c1a2a95b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
index 1dc7daf..d5f420e 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
@@ -246,7 +246,7 @@ public class DockerRabbitMQ {
             .managementUri(managementUri())
             .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL)
             .maxRetries(MAX_THREE_RETRIES)
-            .minDelay(MIN_DELAY_OF_ONE_HUNDRED_MILLISECONDS)
+            .minDelayInMs(MIN_DELAY_OF_ONE_HUNDRED_MILLISECONDS)
             .build();
 
         return new RabbitMQConnectionFactory(rabbitMQConfiguration);

http://git-wip-us.apache.org/repos/asf/james-project/blob/c1a2a95b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConfigurationTest.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConfigurationTest.java b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConfigurationTest.java
index cbdf02f..dbefc59 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConfigurationTest.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConfigurationTest.java
@@ -207,7 +207,7 @@ class RabbitMQConfigurationTest {
             .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL)
             .build();
 
-        assertThat(rabbitMQConfiguration.getMinDelay())
+        assertThat(rabbitMQConfiguration.getMinDelayInMs())
             .isEqualTo(RabbitMQConfiguration.Builder.DEFAULT_MIN_DELAY);
     }
 
@@ -219,10 +219,10 @@ class RabbitMQConfigurationTest {
             .amqpUri(new URI("amqp://james:james@rabbitmq_host:5672"))
             .managementUri(new URI("http://james:james@rabbitmq_host:15672/api/"))
             .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL)
-            .minDelay(minDelay)
+            .minDelayInMs(minDelay)
             .build();
 
-        assertThat(rabbitMQConfiguration.getMinDelay())
+        assertThat(rabbitMQConfiguration.getMinDelayInMs())
             .isEqualTo(minDelay);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/c1a2a95b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
index 024db49..3dce665 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
@@ -56,7 +56,7 @@ class RabbitMQConnectionFactoryTest {
                 .managementUri(URI.create("http://james:james@rabbitmq_host:15672/api/"))
                 .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL)
                 .maxRetries(1)
-                .minDelay(1)
+                .minDelayInMs(1)
                 .build();
 
         RabbitMQConnectionFactory rabbitMQConnectionFactory = new RabbitMQConnectionFactory(rabbitMQConfiguration);


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[03/10] james-project git commit: MAILBOX-374 EventBusTestFixture should rely on java.time.Duration

Posted by bt...@apache.org.
MAILBOX-374 EventBusTestFixture should rely on java.time.Duration


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e255eaeb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e255eaeb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e255eaeb

Branch: refs/heads/master
Commit: e255eaeb02ee2974e1e72e7ed8141e67c81ef3fb
Parents: aa452a1
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 18:03:00 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:33:25 2019 +0700

----------------------------------------------------------------------
 .../mailbox/events/EventBusTestFixture.java     |  6 +--
 .../james/mailbox/events/GroupContract.java     | 30 ++++++-------
 .../james/mailbox/events/KeyContract.java       | 46 ++++++++++----------
 .../mailbox/events/RabbitMQEventBusTest.java    | 16 +++----
 4 files changed, 49 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e255eaeb/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
index d2f3097..e93c96c 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
@@ -84,9 +84,9 @@ public interface EventBusTestFixture {
     MailboxListener.MailboxEvent EVENT = new MailboxListener.MailboxAdded(SESSION_ID, USER, MAILBOX_PATH, TEST_ID, EVENT_ID);
     MailboxListener.MailboxEvent EVENT_2 = new MailboxListener.MailboxAdded(SESSION_ID, USER, MAILBOX_PATH, TEST_ID, EVENT_ID_2);
 
-    int ONE_SECOND = 1000;
-    int THIRTY_SECONDS = 30 * ONE_SECOND;
-    int FIVE_HUNDRED_MS = 500;
+    java.time.Duration ONE_SECOND = java.time.Duration.ofSeconds(1);
+    java.time.Duration THIRTY_SECONDS = java.time.Duration.ofSeconds(30);
+    java.time.Duration FIVE_HUNDRED_MS = java.time.Duration.ofMillis(500);
     MailboxId ID_1 = TEST_ID;
     MailboxId ID_2 = TestId.of(24);
     MailboxId ID_3 = TestId.of(36);

http://git-wip-us.apache.org/repos/asf/james-project/blob/e255eaeb/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
index aa500be..159094b 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
@@ -80,7 +80,7 @@ public interface GroupContract {
 
             eventBus().register(listener, GROUP_A);
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -92,7 +92,7 @@ public interface GroupContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -104,7 +104,7 @@ public interface GroupContract {
             MailboxListener.Added noopEvent = new MailboxListener.Added(MailboxSession.SessionId.of(18), User.fromUsername("bob"), MailboxPath.forUser("bob", "mailbox"), TestId.of(58), ImmutableSortedMap.of(), Event.EventId.random());
             eventBus().dispatch(noopEvent, NO_KEYS).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -128,8 +128,8 @@ public interface GroupContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
-            verify(listener2, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
+            verify(listener2, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -140,7 +140,7 @@ public interface GroupContract {
             registration.unregister();
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -186,7 +186,7 @@ public interface GroupContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -197,7 +197,7 @@ public interface GroupContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -225,7 +225,7 @@ public interface GroupContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -238,8 +238,8 @@ public interface GroupContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener1, timeout(ONE_SECOND).times(1)).event(any());
-            verify(listener2, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener1, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
+            verify(listener2, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
     }
 
@@ -253,7 +253,7 @@ public interface GroupContract {
 
             eventBus2().dispatch(EVENT, NO_KEYS).block();
 
-            verify(mailboxListener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(mailboxListener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -265,7 +265,7 @@ public interface GroupContract {
 
             eventBus2().dispatch(EVENT, NO_KEYS).block();
 
-            verify(mailboxListener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(mailboxListener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -277,7 +277,7 @@ public interface GroupContract {
             eventBus2().dispatch(EVENT, NO_KEYS).block();
 
 
-            verify(mailboxListener, after(FIVE_HUNDRED_MS).never())
+            verify(mailboxListener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -289,7 +289,7 @@ public interface GroupContract {
 
             eventBus2().register(listener, GROUP_A);
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e255eaeb/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
index 47090d0..26ece3b 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
@@ -67,7 +67,7 @@ public interface KeyContract extends EventBusContract {
             MailboxListener.Added noopEvent = new MailboxListener.Added(MailboxSession.SessionId.of(18), User.fromUsername("bob"), MailboxPath.forUser("bob", "mailbox"), TestId.of(58), ImmutableSortedMap.of(), Event.EventId.random());
             eventBus().dispatch(noopEvent, KEY_1).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -89,7 +89,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, NO_KEYS).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -100,7 +100,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_2)).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -111,7 +111,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -133,8 +133,8 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
-            verify(listener2, after(FIVE_HUNDRED_MS).never())
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
+            verify(listener2, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -147,8 +147,8 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
-            verify(listener2, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
+            verify(listener2, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -159,7 +159,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -170,7 +170,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -182,7 +182,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().register(listener, KEY_1);
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -195,7 +195,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -207,7 +207,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -228,7 +228,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1, KEY_2)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -239,7 +239,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1, KEY_2)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -249,7 +249,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -295,7 +295,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(listener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(listener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
     }
 
@@ -309,7 +309,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus2().dispatch(EVENT, KEY_1).block();
 
-            verify(mailboxListener, timeout(ONE_SECOND).times(1)).event(any());
+            verify(mailboxListener, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -320,7 +320,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus2().dispatch(EVENT, ImmutableSet.of(KEY_1)).block();
 
-            verify(mailboxListener, after(FIVE_HUNDRED_MS).never())
+            verify(mailboxListener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -334,8 +334,8 @@ public interface KeyContract extends EventBusContract {
 
             eventBus2().dispatch(EVENT, KEY_1).block();
 
-            verify(mailboxListener1, timeout(ONE_SECOND).times(1)).event(any());
-            verify(mailboxListener2, timeout(ONE_SECOND).times(1)).event(any());
+            verify(mailboxListener1, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
+            verify(mailboxListener2, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
         @Test
@@ -346,7 +346,7 @@ public interface KeyContract extends EventBusContract {
 
             eventBus().register(listener, KEY_1);
 
-            verify(listener, after(FIVE_HUNDRED_MS).never())
+            verify(listener, after(FIVE_HUNDRED_MS.toMillis()).never())
                 .event(any());
         }
 
@@ -361,7 +361,7 @@ public interface KeyContract extends EventBusContract {
             eventBus2().dispatch(EVENT, KEY_1).block();
 
             verify(mailboxListener2, times(1)).event(any());
-            verify(mailboxListener1, timeout(ONE_SECOND).times(1)).event(any());
+            verify(mailboxListener1, timeout(ONE_SECOND.toMillis()).times(1)).event(any());
         }
 
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e255eaeb/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
index 38ca6c5..2d638b5 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
@@ -320,7 +320,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
                 rabbitMQExtension.getRabbitMQ().unpause();
 
                 eventBus.dispatch(EVENT, NO_KEYS).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -332,7 +332,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
                 rabbitMQExtension.getRabbitMQ().restart();
 
                 eventBus.dispatch(EVENT, NO_KEYS).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -345,7 +345,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
                 eventBus.register(listener, GROUP_A);
 
                 eventBus.dispatch(EVENT, NO_KEYS).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -357,7 +357,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
                 rabbitMQExtension.getRabbitMQ().restart();
 
                 eventBus.dispatch(EVENT, KEY_1).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -370,7 +370,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
                 eventBus.register(listener, KEY_1);
 
                 eventBus.dispatch(EVENT, KEY_1).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -387,7 +387,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
 
                 eventBus.register(listener, GROUP_A);
                 eventBus.dispatch(EVENT, NO_KEYS).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -405,7 +405,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
                 rabbitMQExtension.getRabbitMQ().unpause();
 
                 eventBus.dispatch(EVENT, KEY_1).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test
@@ -423,7 +423,7 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
 
                 eventBus.register(listener, KEY_1);
                 eventBus.dispatch(EVENT, KEY_1).block();
-                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+                verify(listener, after(THIRTY_SECONDS.toMillis()).times(1)).event(EVENT);
             }
 
             @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[09/10] james-project git commit: MAILBOX-364 Move event related classes in the event package of mailbox-api

Posted by bt...@apache.org.
http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
index d8418be..f0e2acf 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
@@ -29,8 +29,6 @@ import java.nio.charset.StandardCharsets;
 import java.util.Optional;
 
 import org.apache.james.event.json.EventSerializer;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.util.MDCBuilder;
 import org.apache.james.util.MDCStructuredLogger;
 import org.apache.james.util.StructuredLogger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerExecutor.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerExecutor.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerExecutor.java
index cea4d9e..9a7fd33 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerExecutor.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerExecutor.java
@@ -23,8 +23,6 @@ import static org.apache.james.mailbox.events.EventBus.Metrics.timerName;
 
 import java.io.Closeable;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.metrics.api.TimeMetric;
 import org.apache.james.util.MDCBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerRegistry.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerRegistry.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerRegistry.java
index 5fc89bd..63caf00 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerRegistry.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/MailboxListenerRegistry.java
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.events;
 
-import org.apache.james.mailbox.MailboxListener;
-
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimaps;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
index ecfeb0b..2a9a07d 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
@@ -27,8 +27,6 @@ import javax.inject.Inject;
 
 import org.apache.james.backend.rabbitmq.RabbitMQConnectionFactory;
 import org.apache.james.event.json.EventSerializer;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.metrics.api.MetricFactory;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/MailboxListenerRegistryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/MailboxListenerRegistryTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/MailboxListenerRegistryTest.java
index ce388f2..4033f6f 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/MailboxListenerRegistryTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/MailboxListenerRegistryTest.java
@@ -26,7 +26,6 @@ import java.time.Duration;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.util.concurrency.ConcurrentTestRunner;
 import org.junit.jupiter.api.BeforeEach;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
index 2d638b5..d001841 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
@@ -57,8 +57,6 @@ import org.apache.james.backend.rabbitmq.RabbitMQConnectionFactory;
 import org.apache.james.backend.rabbitmq.RabbitMQExtension;
 import org.apache.james.backend.rabbitmq.RabbitMQManagementAPI;
 import org.apache.james.event.json.EventSerializer;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.model.TestMessageId;
 import org.apache.james.metrics.api.NoopMetricFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
index 592d366..4b01cba 100644
--- a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
+++ b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
@@ -28,11 +28,12 @@ import org.apache.james.core.quota.{QuotaCount, QuotaSize, QuotaValue}
 import org.apache.james.core.{Domain, User}
 import org.apache.james.event.json.DTOs.SystemFlag.SystemFlag
 import org.apache.james.event.json.DTOs.{ACLDiff, Flags, MailboxPath, Quota, SystemFlag, UserFlag}
-import org.apache.james.mailbox.Event.EventId
-import org.apache.james.mailbox.MailboxListener.{Added => JavaAdded, Expunged => JavaExpunged, FlagsUpdated => JavaFlagsUpdated, MailboxACLUpdated => JavaMailboxACLUpdated, MailboxAdded => JavaMailboxAdded, MailboxDeletion => JavaMailboxDeletion, MailboxRenamed => JavaMailboxRenamed, QuotaUsageUpdatedEvent => JavaQuotaUsageUpdatedEvent}
 import org.apache.james.mailbox.MailboxSession.SessionId
+import org.apache.james.mailbox.events.Event.EventId
+import org.apache.james.mailbox.events.MailboxListener.{Added => JavaAdded, Expunged => JavaExpunged, FlagsUpdated => JavaFlagsUpdated, MailboxACLUpdated => JavaMailboxACLUpdated, MailboxAdded => JavaMailboxAdded, MailboxDeletion => JavaMailboxDeletion, MailboxRenamed => JavaMailboxRenamed, QuotaUsageUpdatedEvent => JavaQuotaUsageUpdatedEvent}
+import org.apache.james.mailbox.events.{MessageMoveEvent => JavaMessageMoveEvent, Event => JavaEvent}
 import org.apache.james.mailbox.model.{MailboxId, MessageId, MessageMoves, QuotaRoot, MailboxACL => JavaMailboxACL, MessageMetaData => JavaMessageMetaData, Quota => JavaQuota}
-import org.apache.james.mailbox.{MessageUid, Event => JavaEvent, MessageMoveEvent => JavaMessageMoveEvent}
+import org.apache.james.mailbox.{MessageUid, events}
 import play.api.libs.json.{JsError, JsNull, JsNumber, JsObject, JsResult, JsString, JsSuccess, Json, OFormat, Reads, Writes}
 
 import scala.collection.JavaConverters._

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
index 4429a1f..155d41e 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/AddedSerializationTest.java
@@ -34,9 +34,9 @@ import javax.mail.Flags;
 
 import org.apache.james.core.User;
 import org.apache.james.mailbox.FlagsBuilder;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
index b04b552..513ccea 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/ExpungedSerializationTest.java
@@ -34,9 +34,9 @@ import javax.mail.Flags;
 
 import org.apache.james.core.User;
 import org.apache.james.mailbox.FlagsBuilder;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
index 5e7fd38..9a0f19d 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/FlagsUpdatedSerializationTest.java
@@ -32,9 +32,9 @@ import javax.mail.Flags;
 
 import org.apache.james.core.User;
 import org.apache.james.mailbox.FlagsBuilder;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
index 7436899..d0f6c6a 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxACLUpdatedEventSerializationTest.java
@@ -28,9 +28,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.NoSuchElementException;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxAddedSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxAddedSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxAddedSerializationTest.java
index 09056d3..baf19c0 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxAddedSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxAddedSerializationTest.java
@@ -28,8 +28,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.NoSuchElementException;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
index ef20655..a634b8a 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
@@ -32,8 +32,8 @@ import java.util.Optional;
 import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.QuotaRoot;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxRenamedSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxRenamedSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxRenamedSerializationTest.java
index 94ec114..43fc727 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxRenamedSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxRenamedSerializationTest.java
@@ -29,8 +29,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.NoSuchElementException;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/MessageMoveEventSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/MessageMoveEventSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/MessageMoveEventSerializationTest.java
index 95190f4..28b3630 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/MessageMoveEventSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/MessageMoveEventSerializationTest.java
@@ -28,8 +28,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import java.util.NoSuchElementException;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MessageMoveEvent;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.model.MessageMoves;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.model.TestMessageId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
index 9a81746..1da0211 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/QuotaUsageUpdatedEventSerializationTest.java
@@ -32,7 +32,7 @@ import java.util.Optional;
 import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.junit.jupiter.api.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/json/src/test/java/org/apache/james/event/json/SerializerFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/SerializerFixture.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/SerializerFixture.java
index 14eb14d..19c402d 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/SerializerFixture.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/SerializerFixture.java
@@ -20,7 +20,7 @@
 package org.apache.james.event.json;
 
 
-import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.model.TestMessageId;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java
index 900d0fd..c19e834 100644
--- a/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java
+++ b/mailbox/plugin/quota-mailing/src/main/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdCrossingListener.java
@@ -28,9 +28,9 @@ import org.apache.james.eventsourcing.EventSourcingSystem;
 import org.apache.james.eventsourcing.Subscriber;
 import org.apache.james.eventsourcing.eventstore.EventStore;
 import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;
 import org.apache.james.mailbox.quota.mailing.commands.DetectThresholdCrossing;
 import org.apache.james.mailbox.quota.mailing.commands.DetectThresholdCrossingHandler;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
index adfdccf..03127e5 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdConfigurationChangesTest.java
@@ -29,7 +29,7 @@ import static org.apache.james.mailbox.quota.model.QuotaThresholdFixture.mailetC
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.eventsourcing.eventstore.EventStore;
-import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
index ae4e936..14b4ab9 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdListenersTestSystem.java
@@ -21,7 +21,7 @@ package org.apache.james.mailbox.quota.mailing.listeners;
 
 import org.apache.james.eventsourcing.eventstore.EventStore;
 import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.InVMEventBus;
 import org.apache.james.mailbox.events.RegistrationKey;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
index 3f76a88..9213051 100644
--- a/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
+++ b/mailbox/plugin/quota-mailing/src/test/java/org/apache/james/mailbox/quota/mailing/listeners/QuotaThresholdMailingIntegrationTest.java
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.time.Duration;
 
 import org.apache.james.eventsourcing.eventstore.EventStore;
-import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
 import org.apache.james.mailbox.quota.mailing.QuotaMailingListenerConfiguration;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java b/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
index 25c5613..0f167a3 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListener.java
@@ -23,9 +23,9 @@ import javax.inject.Named;
 
 import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.quota.search.elasticsearch.QuotaRatioElasticSearchConstants;
 import org.apache.james.quota.search.elasticsearch.json.QuotaRatioToElasticSearchJson;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJson.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJson.java b/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJson.java
index a03577f..12f9629 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJson.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/main/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJson.java
@@ -22,7 +22,7 @@ package org.apache.james.quota.search.elasticsearch.json;
 import javax.inject.Inject;
 
 import org.apache.james.core.Domain;
-import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent;
+import org.apache.james.mailbox.events.MailboxListener.QuotaUsageUpdatedEvent;
 import org.apache.james.mailbox.model.QuotaRatio;
 
 import com.fasterxml.jackson.core.JsonProcessingException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
index cd369f3..a037668 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/events/ElasticSearchQuotaMailboxListenerTest.java
@@ -33,7 +33,7 @@ import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.backends.es.utils.TestingClientProvider;
-import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.quota.QuotaFixture.Counts;
 import org.apache.james.mailbox.quota.QuotaFixture.Sizes;
 import org.apache.james.mailbox.store.event.EventFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java
index b5eb274..4f42c92 100644
--- a/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java
+++ b/mailbox/plugin/quota-search-elasticsearch/src/test/java/org/apache/james/quota/search/elasticsearch/json/QuotaRatioToElasticSearchJsonTest.java
@@ -27,8 +27,8 @@ import java.util.Optional;
 
 import org.apache.james.core.Domain;
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener.QuotaUsageUpdatedEvent;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MailboxListener.QuotaUsageUpdatedEvent;
 import org.apache.james.mailbox.model.QuotaRoot;
 import org.apache.james.mailbox.quota.QuotaFixture;
 import org.apache.james.mailbox.store.event.EventFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/spamassassin/src/main/java/org/apache/james/mailbox/spamassassin/SpamAssassinListener.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/spamassassin/src/main/java/org/apache/james/mailbox/spamassassin/SpamAssassinListener.java b/mailbox/plugin/spamassassin/src/main/java/org/apache/james/mailbox/spamassassin/SpamAssassinListener.java
index 1b83028..b50ecba 100644
--- a/mailbox/plugin/spamassassin/src/main/java/org/apache/james/mailbox/spamassassin/SpamAssassinListener.java
+++ b/mailbox/plugin/spamassassin/src/main/java/org/apache/james/mailbox/spamassassin/SpamAssassinListener.java
@@ -24,13 +24,13 @@ import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
-import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageMoveEvent;
 import org.apache.james.mailbox.Role;
 import org.apache.james.mailbox.SystemMailboxesProvider;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageRange;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
index 1a66b30..f269a43 100644
--- a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
+++ b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java
@@ -33,11 +33,11 @@ import javax.mail.Flags;
 import javax.mail.util.SharedByteArrayInputStream;
 
 import org.apache.james.mailbox.DefaultMailboxes;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
-import org.apache.james.mailbox.MessageMoveEvent;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.events.MailboxListener;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
index 81fc691..921083a 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
@@ -38,7 +38,6 @@ import javax.mail.internet.SharedInputStream;
 import javax.mail.util.SharedFileInputStream;
 
 import org.apache.commons.io.input.TeeInputStream;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxManager.MessageCapabilities;
 import org.apache.james.mailbox.MailboxPathLocker;
@@ -48,6 +47,7 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.ReadOnlyException;
 import org.apache.james.mailbox.model.ComposedMessageId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 5ad8d09..65a5a27 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -27,12 +27,12 @@ import java.util.SortedMap;
 import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageMoveEvent;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MailboxListener;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxAnnotationListener.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxAnnotationListener.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxAnnotationListener.java
index 5c293cb..1b38e37 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxAnnotationListener.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxAnnotationListener.java
@@ -22,10 +22,10 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SpamEventListener.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SpamEventListener.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SpamEventListener.java
index d908a98..4e8e9c9 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SpamEventListener.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SpamEventListener.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.event;
 
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 
 public interface SpamEventListener extends MailboxListener.GroupMailboxListener {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
index cf6cace..79bb030 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdater.java
@@ -22,10 +22,10 @@ import java.time.Instant;
 
 import javax.inject.Inject;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.RegistrationKey;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.QuotaRoot;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
index a1ffc3d..53d9ac7 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
@@ -22,10 +22,10 @@ import java.util.Collection;
 import java.util.List;
 import java.util.stream.Stream;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
@@ -59,7 +59,7 @@ public abstract class ListeningMessageSearchIndex implements MessageSearchIndex,
     }
 
     /**
-     * Process the {@link org.apache.james.mailbox.Event} and update the index if
+     * Process the {@link Event} and update the index if
      * something relevant is received
      */
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
index 50ffb55..36f59cb 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerSideEffectTest.java
@@ -31,16 +31,16 @@ import javax.mail.Flags;
 
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MessageManager.FlagsUpdateMode;
-import org.apache.james.mailbox.MessageMoveEvent;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.InVMEventBus;
+import org.apache.james.mailbox.events.MailboxListener;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.OverQuotaException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
index ee68c71..22160cd 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
@@ -31,10 +31,10 @@ import java.util.Optional;
 
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
index b942af1..5367381 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/quota/ListeningCurrentQuotaUpdaterTest.java
@@ -36,10 +36,10 @@ import javax.mail.Flags;
 import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.QuotaRoot;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java
index 2941f6d..3ef9ab3 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/IdleProcessor.java
@@ -42,11 +42,11 @@ import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.api.process.SelectedMailbox;
 import org.apache.james.imap.message.request.IdleRequest;
 import org.apache.james.imap.message.response.ContinuationResponse;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.Registration;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.util.MDCBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
index 287e18d..c1ec72d 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
@@ -34,14 +34,14 @@ import javax.mail.Flags.Flag;
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.api.process.SelectedMailbox;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.Registration;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 0baae20..f6e025d 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -32,14 +32,14 @@ import org.apache.commons.lang3.NotImplementedException;
 import org.apache.james.imap.api.ImapSessionState;
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.process.ImapSession;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.InVMEventBus;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
index d89a36b..77b1817 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
@@ -37,7 +37,6 @@ import javax.mail.Flags;
 
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.process.ImapSession;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
@@ -45,6 +44,7 @@ import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 6c95c9c..2b677fc 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -27,7 +27,6 @@ import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.mailbox.AttachmentManager;
 import org.apache.james.mailbox.BlobManager;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MessageIdManager;
@@ -70,6 +69,7 @@ import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.indexer.MessageIdReIndexer;
 import org.apache.james.mailbox.indexer.ReIndexer;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
index 1684aa6..1850879 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
@@ -20,12 +20,12 @@
 package org.apache.james.modules.mailbox;
 
 import org.apache.james.backends.cassandra.components.CassandraModule;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
 import org.apache.james.mailbox.cassandra.quota.CassandraGlobalMaxQuotaDao;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerDomainMaxQuotaDao;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaDao;
 import org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;
 import org.apache.james.mailbox.quota.MaxQuotaManager;
 import org.apache.james.mailbox.quota.QuotaManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
index 006d323..4a72fe5 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -34,7 +34,6 @@ import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.backends.es.ClientProviderImpl;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.elasticsearch.ElasticSearchMailboxConfiguration;
 import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.elasticsearch.MailboxElasticSearchConstants;
@@ -42,6 +41,7 @@ import org.apache.james.mailbox.elasticsearch.MailboxIndexCreationUtil;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchQuotaSearcherModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchQuotaSearcherModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchQuotaSearcherModule.java
index 80f2575..0b49e51 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchQuotaSearcherModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchQuotaSearcherModule.java
@@ -29,7 +29,7 @@ import javax.inject.Named;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.backends.es.ElasticSearchIndexer;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.quota.search.QuotaSearcher;
 import org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaConfiguration;
 import org.apache.james.quota.search.elasticsearch.ElasticSearchQuotaSearcher;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
index 1ceeb0d..b3afb95 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
@@ -24,7 +24,6 @@ import javax.inject.Singleton;
 
 import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
 import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.SubscriptionManager;
@@ -32,6 +31,7 @@ import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.indexer.ReIndexer;
 import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.JPAMailboxSessionMapperFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
index 925ea99..45c1b0b 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.modules.mailbox;
 
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaManager;
 import org.apache.james.mailbox.jpa.quota.JpaCurrentQuotaManager;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java
index 4b93211..7b5c6de 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/LuceneSearchMailboxModule.java
@@ -22,7 +22,7 @@ package org.apache.james.modules.mailbox;
 import java.io.IOException;
 
 import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.apache.james.mailbox.store.search.MessageSearchIndex;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
index e09153d..fcf5af6 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/DefaultEventModule.java
@@ -25,10 +25,10 @@ import javax.inject.Inject;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.EventDeadLetters;
 import org.apache.james.mailbox.events.InVMEventBus;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.MemoryEventDeadLetters;
 import org.apache.james.mailbox.events.RetryBackoffConfiguration;
 import org.apache.james.mailbox.events.delivery.EventDelivery;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenerFactory.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenerFactory.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenerFactory.java
index 4c39661..7f90b92 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenerFactory.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenerFactory.java
@@ -23,7 +23,7 @@ import java.util.Optional;
 import javax.inject.Inject;
 
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 
 import com.google.common.base.Preconditions;
 import com.google.inject.Injector;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoader.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoader.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoader.java
index 0f0b458..63969ef 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoader.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoader.java
@@ -19,8 +19,8 @@
 package org.apache.james.modules.mailbox;
 
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 
 public interface MailboxListenersLoader {
     Pair<Group, MailboxListener> createListener(ListenerConfiguration configuration);

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImpl.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImpl.java
index e1721fb..17206d3 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImpl.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImpl.java
@@ -23,10 +23,10 @@ import java.util.Set;
 import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.GenericGroup;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.utils.ExtendedClassLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/NoopMailboxListener.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/NoopMailboxListener.java b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/NoopMailboxListener.java
index 70a544d..0fea4d6 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/NoopMailboxListener.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/mailbox/NoopMailboxListener.java
@@ -18,9 +18,9 @@
  ****************************************************************/
 package org.apache.james.modules.mailbox;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 
 public class NoopMailboxListener implements MailboxListener.GroupMailboxListener {
     private static class NoopMailboxListenerGroup extends Group {}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/mailbox/src/test/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImplTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/test/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImplTest.java b/server/container/guice/mailbox/src/test/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImplTest.java
index bcdbcc6..58ce295 100644
--- a/server/container/guice/mailbox/src/test/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImplTest.java
+++ b/server/container/guice/mailbox/src/test/java/org/apache/james/modules/mailbox/MailboxListenersLoaderImplTest.java
@@ -32,10 +32,10 @@ import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.events.GenericGroup;
 import org.apache.james.mailbox.events.Group;
 import org.apache.james.mailbox.events.InVMEventBus;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.delivery.InVmEventDelivery;
 import org.apache.james.metrics.api.NoopMetricFactory;
 import org.apache.james.utils.ExtendedClassLoader;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index 3bb2430..1f01474 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -27,12 +27,12 @@ import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
 import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
 import org.apache.james.mailbox.AttachmentManager;
 import org.apache.james.mailbox.BlobManager;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.RightManager;
 import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
index 9216f78..6b81bbe 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.modules.mailbox;
 
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
 import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
 import org.apache.james.mailbox.quota.CurrentQuotaManager;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
index 307f4b5..52b756b 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -38,9 +38,9 @@ import org.apache.james.jmap.utils.HtmlTextExtractor;
 import org.apache.james.jmap.utils.JsoupHtmlTextExtractor;
 import org.apache.james.jwt.JwtConfiguration;
 import org.apache.james.lifecycle.api.Configurable;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.modules.server.CamelMailetContainerModule;
 import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
 import org.apache.james.server.core.configuration.FileConfigurationProvider;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/container/guice/protocols/jmap/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/utils/JmapGuiceProbe.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
index 247aa86..3c97d25 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/utils/JmapGuiceProbe.java
@@ -28,11 +28,11 @@ import org.apache.james.jmap.api.vacation.AccountId;
 import org.apache.james.jmap.api.vacation.Vacation;
 import org.apache.james.jmap.api.vacation.VacationPatch;
 import org.apache.james.jmap.api.vacation.VacationRepository;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.events.EventBus;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
index c8028bf..be6d055 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java
@@ -79,10 +79,10 @@ import org.apache.james.jmap.MessageAppender;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.jmap.categories.BasicFeature;
 import org.apache.james.mailbox.DefaultMailboxes;
-import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.FlagsBuilder;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.Role;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Attachment;
 import org.apache.james.mailbox.model.ComposedMessageId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
index ac8f2a1..47434e8 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SpamAssassinModule.java
@@ -23,9 +23,9 @@ import java.util.Optional;
 import javax.inject.Singleton;
 
 import org.apache.commons.configuration.BaseConfiguration;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.SystemMailboxesProvider;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.spamassassin.SpamAssassin;
 import org.apache.james.mailbox.spamassassin.SpamAssassinConfiguration;
 import org.apache.james.mailbox.spamassassin.SpamAssassinListener;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
index d56b616..64a906c 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
@@ -23,13 +23,13 @@ import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.RightManager;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxACL.Entry;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
index 60e9532..8edb7d9 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
@@ -21,12 +21,12 @@ package org.apache.james.jmap.event;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxACL.Entry;


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[02/10] james-project git commit: MAILBOX-374 RabbitMQConnectionFactory should rely on reactor for retries

Posted by bt...@apache.org.
MAILBOX-374 RabbitMQConnectionFactory should rely on reactor for retries


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/603de62f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/603de62f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/603de62f

Branch: refs/heads/master
Commit: 603de62f3044de9e9d10ac19b0ff6cc8400dd217
Parents: c47b846
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 13:39:00 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:31:40 2019 +0700

----------------------------------------------------------------------
 .../rabbitmq/RabbitMQConnectionFactory.java     | 27 +++++++++-----------
 .../james/backend/rabbitmq/DockerRabbitMQ.java  |  9 +------
 .../rabbitmq/RabbitMQConnectionFactoryTest.java | 22 +++-------------
 3 files changed, 17 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/603de62f/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
index 2f901f4..e02fb28 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
@@ -18,27 +18,24 @@
  ****************************************************************/
 package org.apache.james.backend.rabbitmq;
 
-import java.util.concurrent.ExecutionException;
+import java.time.Duration;
 
 import javax.inject.Inject;
 
-import org.apache.james.util.retry.RetryExecutorUtil;
-
-import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
 import com.rabbitmq.client.Connection;
 import com.rabbitmq.client.ConnectionFactory;
 
-public class RabbitMQConnectionFactory {
+import reactor.core.publisher.Mono;
+import reactor.core.scheduler.Schedulers;
 
-    private final AsyncRetryExecutor executor;
+public class RabbitMQConnectionFactory {
     private final ConnectionFactory connectionFactory;
 
     private final int maxRetries;
     private final int minDelay;
 
     @Inject
-    public RabbitMQConnectionFactory(RabbitMQConfiguration rabbitMQConfiguration, AsyncRetryExecutor executor) {
-        this.executor = executor;
+    public RabbitMQConnectionFactory(RabbitMQConfiguration rabbitMQConfiguration) {
         this.connectionFactory = from(rabbitMQConfiguration);
         this.maxRetries = rabbitMQConfiguration.getMaxRetries();
         this.minDelay = rabbitMQConfiguration.getMinDelay();
@@ -55,12 +52,12 @@ public class RabbitMQConnectionFactory {
     }
 
     public Connection create() {
-        try {
-            return RetryExecutorUtil.retryOnExceptions(executor, maxRetries, minDelay, Exception.class)
-                    .getWithRetry(context -> connectionFactory.newConnection())
-                    .get();
-        } catch (InterruptedException | ExecutionException e) {
-            throw new RuntimeException(e);
-        }
+        return connectionMono().block();
+    }
+
+    public Mono<Connection> connectionMono() {
+        return Mono.fromCallable(connectionFactory::newConnection)
+            .retryBackoff(maxRetries, Duration.ofMillis(minDelay))
+            .publishOn(Schedulers.elastic());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/603de62f/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
index 0d32047..1dc7daf 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
@@ -25,11 +25,8 @@ import java.net.URISyntaxException;
 import java.time.Duration;
 import java.util.Optional;
 import java.util.UUID;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
 
 import org.apache.http.client.utils.URIBuilder;
-import org.apache.james.util.concurrent.NamedThreadFactory;
 import org.apache.james.util.docker.Images;
 import org.apache.james.util.docker.RateLimiters;
 import org.slf4j.Logger;
@@ -43,7 +40,6 @@ import org.testcontainers.containers.wait.strategy.WaitStrategy;
 
 import com.github.fge.lambdas.consumers.ThrowingConsumer;
 import com.google.common.collect.ImmutableMap;
-import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
 import com.rabbitmq.client.Address;
 import com.rabbitmq.client.ConnectionFactory;
 
@@ -253,9 +249,6 @@ public class DockerRabbitMQ {
             .minDelay(MIN_DELAY_OF_ONE_HUNDRED_MILLISECONDS)
             .build();
 
-        ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
-        return new RabbitMQConnectionFactory(
-            rabbitMQConfiguration,
-            new AsyncRetryExecutor(Executors.newSingleThreadScheduledExecutor(threadFactory)));
+        return new RabbitMQConnectionFactory(rabbitMQConfiguration);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/603de62f/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
index 5a357a7..024db49 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactoryTest.java
@@ -22,24 +22,10 @@ import static org.apache.james.backend.rabbitmq.RabbitMQFixture.DEFAULT_MANAGEME
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import java.net.URI;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
 
-import org.apache.james.util.concurrent.NamedThreadFactory;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
-
 class RabbitMQConnectionFactoryTest {
-
-    private ScheduledExecutorService scheduledExecutor;
-
-    @BeforeEach
-    void setUp() throws Exception {
-        scheduledExecutor = Executors.newSingleThreadScheduledExecutor(NamedThreadFactory.withClassName(getClass()));
-    }
-
     @Test
     void creatingAFactoryShouldWorkWhenConfigurationIsValid() {
         RabbitMQConfiguration rabbitMQConfiguration = RabbitMQConfiguration.builder()
@@ -48,7 +34,7 @@ class RabbitMQConnectionFactoryTest {
             .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL)
             .build();
 
-        new RabbitMQConnectionFactory(rabbitMQConfiguration, new AsyncRetryExecutor(scheduledExecutor));
+        new RabbitMQConnectionFactory(rabbitMQConfiguration);
     }
 
     @Test
@@ -59,7 +45,7 @@ class RabbitMQConnectionFactoryTest {
             .managementCredentials(DEFAULT_MANAGEMENT_CREDENTIAL)
             .build();
 
-        assertThatThrownBy(() -> new RabbitMQConnectionFactory(rabbitMQConfiguration, new AsyncRetryExecutor(scheduledExecutor)))
+        assertThatThrownBy(() -> new RabbitMQConnectionFactory(rabbitMQConfiguration))
             .isInstanceOf(RuntimeException.class);
     }
 
@@ -73,9 +59,9 @@ class RabbitMQConnectionFactoryTest {
                 .minDelay(1)
                 .build();
 
-        RabbitMQConnectionFactory rabbitMQConnectionFactory = new RabbitMQConnectionFactory(rabbitMQConfiguration, new AsyncRetryExecutor(scheduledExecutor));
+        RabbitMQConnectionFactory rabbitMQConnectionFactory = new RabbitMQConnectionFactory(rabbitMQConfiguration);
 
-        assertThatThrownBy(() -> rabbitMQConnectionFactory.create())
+        assertThatThrownBy(rabbitMQConnectionFactory::create)
             .isInstanceOf(RuntimeException.class);
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[10/10] james-project git commit: MAILBOX-364 Move event related classes in the event package of mailbox-api

Posted by bt...@apache.org.
MAILBOX-364 Move event related classes in the event package of mailbox-api


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/df5d678c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/df5d678c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/df5d678c

Branch: refs/heads/master
Commit: df5d678cd43319ba7afca9baabcfc27b338b1898
Parents: 4270f4f
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Jan 23 17:58:23 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:54:50 2019 +0700

----------------------------------------------------------------------
 .../java/org/apache/james/mailbox/Event.java    |  83 ---
 .../apache/james/mailbox/MailboxListener.java   | 582 ------------------
 .../apache/james/mailbox/MessageMoveEvent.java  | 152 -----
 .../org/apache/james/mailbox/events/Event.java  |  83 +++
 .../apache/james/mailbox/events/EventBus.java   |   3 -
 .../james/mailbox/events/EventDeadLetters.java  |   2 -
 .../james/mailbox/events/MailboxListener.java   | 583 +++++++++++++++++++
 .../james/mailbox/events/MessageMoveEvent.java  | 153 +++++
 .../org/apache/james/mailbox/EventTest.java     |   1 +
 .../james/mailbox/MailboxListenerTest.java      |   2 +
 .../james/mailbox/MailboxManagerStressTest.java |   1 +
 .../james/mailbox/MailboxManagerTest.java       |   2 +
 .../james/mailbox/MessageMoveEventTest.java     |   3 +-
 .../mailbox/events/ErrorHandlingContract.java   |   2 -
 .../mailbox/events/EventBusTestFixture.java     |   2 -
 .../events/EventDeadLettersContract.java        |   2 -
 .../james/mailbox/events/GroupContract.java     |   2 -
 .../james/mailbox/events/KeyContract.java       |   2 -
 .../james/mailbox/model/MessageMovesTest.java   |   2 +-
 .../james/mailbox/util/EventCollector.java      |   4 +-
 .../CacheInvalidatingMailboxListener.java       |   4 +-
 .../MailboxOperationLoggingListener.java        |   4 +-
 .../james/mailbox/events/InVMEventBus.java      |   2 -
 .../mailbox/events/MemoryEventDeadLetters.java  |   2 -
 .../mailbox/events/delivery/EventDelivery.java  |   4 +-
 .../events/delivery/InVmEventDelivery.java      |   4 +-
 .../events/delivery/InVmEventDeliveryTest.java  |   2 +-
 .../james/mailbox/events/EventDispatcher.java   |   2 -
 .../mailbox/events/GroupConsumerRetry.java      |   1 -
 .../james/mailbox/events/GroupRegistration.java |   2 -
 .../events/GroupRegistrationHandler.java        |   1 -
 .../mailbox/events/KeyRegistrationHandler.java  |   2 -
 .../mailbox/events/MailboxListenerExecutor.java |   2 -
 .../mailbox/events/MailboxListenerRegistry.java |   2 -
 .../james/mailbox/events/RabbitMQEventBus.java  |   2 -
 .../events/MailboxListenerRegistryTest.java     |   1 -
 .../mailbox/events/RabbitMQEventBusTest.java    |   2 -
 .../james/event/json/EventSerializer.scala      |   7 +-
 .../event/json/AddedSerializationTest.java      |   2 +-
 .../event/json/ExpungedSerializationTest.java   |   2 +-
 .../json/FlagsUpdatedSerializationTest.java     |   2 +-
 ...MailboxACLUpdatedEventSerializationTest.java |   2 +-
 .../json/MailboxAddedSerializationTest.java     |   2 +-
 .../json/MailboxDeletionSerializationTest.java  |   2 +-
 .../json/MailboxRenamedSerializationTest.java   |   2 +-
 .../json/MessageMoveEventSerializationTest.java |   4 +-
 ...QuotaUsageUpdatedEventSerializationTest.java |   2 +-
 .../james/event/json/SerializerFixture.java     |   2 +-
 .../QuotaThresholdCrossingListener.java         |   4 +-
 .../QuotaThresholdConfigurationChangesTest.java |   2 +-
 .../QuotaThresholdListenersTestSystem.java      |   2 +-
 .../QuotaThresholdMailingIntegrationTest.java   |   2 +-
 .../ElasticSearchQuotaMailboxListener.java      |   4 +-
 .../json/QuotaRatioToElasticSearchJson.java     |   2 +-
 .../ElasticSearchQuotaMailboxListenerTest.java  |   2 +-
 .../json/QuotaRatioToElasticSearchJsonTest.java |   4 +-
 .../spamassassin/SpamAssassinListener.java      |   4 +-
 .../spamassassin/SpamAssassinListenerTest.java  |   4 +-
 .../mailbox/store/StoreMessageManager.java      |   2 +-
 .../james/mailbox/store/event/EventFactory.java |   6 +-
 .../store/event/MailboxAnnotationListener.java  |   4 +-
 .../mailbox/store/event/SpamEventListener.java  |   2 +-
 .../quota/ListeningCurrentQuotaUpdater.java     |   4 +-
 .../search/ListeningMessageSearchIndex.java     |   6 +-
 .../AbstractMessageIdManagerSideEffectTest.java |   4 +-
 .../event/MailboxAnnotationListenerTest.java    |   4 +-
 .../quota/ListeningCurrentQuotaUpdaterTest.java |   4 +-
 .../james/imap/processor/IdleProcessor.java     |   4 +-
 .../processor/base/SelectedMailboxImpl.java     |   4 +-
 .../base/MailboxEventAnalyserTest.java          |   4 +-
 .../processor/base/SelectedMailboxImplTest.java |   2 +-
 .../modules/mailbox/CassandraMailboxModule.java |   2 +-
 .../modules/mailbox/CassandraQuotaModule.java   |   2 +-
 .../mailbox/ElasticSearchMailboxModule.java     |   2 +-
 .../ElasticSearchQuotaSearcherModule.java       |   2 +-
 .../james/modules/mailbox/JPAMailboxModule.java |   2 +-
 .../james/modules/mailbox/JpaQuotaModule.java   |   2 +-
 .../mailbox/LuceneSearchMailboxModule.java      |   2 +-
 .../modules/mailbox/DefaultEventModule.java     |   2 +-
 .../modules/mailbox/MailboxListenerFactory.java |   2 +-
 .../modules/mailbox/MailboxListenersLoader.java |   2 +-
 .../mailbox/MailboxListenersLoaderImpl.java     |   2 +-
 .../modules/mailbox/NoopMailboxListener.java    |   4 +-
 .../mailbox/MailboxListenersLoaderImplTest.java |   2 +-
 .../modules/mailbox/MemoryMailboxModule.java    |   2 +-
 .../modules/mailbox/MemoryQuotaModule.java      |   2 +-
 .../java/org/apache/james/jmap/JMAPModule.java  |   2 +-
 .../org/apache/james/utils/JmapGuiceProbe.java  |   2 +-
 .../integration/SetMessagesMethodTest.java      |   4 +-
 .../methods/integration/SpamAssassinModule.java |   2 +-
 .../event/PropagateLookupRightListener.java     |   4 +-
 .../event/PropagateLookupRightListenerTest.java |   2 +-
 92 files changed, 917 insertions(+), 945 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
deleted file mode 100644
index bb26f1e..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox;
-
-import java.util.Objects;
-import java.util.UUID;
-
-import org.apache.james.core.User;
-
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
-
-public interface Event {
-
-    class EventId {
-        public static EventId of(UUID uuid) {
-            return new EventId(uuid);
-        }
-
-        public static EventId random() {
-            return new EventId(UUID.randomUUID());
-        }
-
-        public static EventId of(String serialized) {
-            return of(UUID.fromString(serialized));
-        }
-
-        private final UUID id;
-
-        private EventId(UUID id) {
-            Preconditions.checkNotNull(id);
-            this.id = id;
-        }
-
-        public UUID getId() {
-            return id;
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof EventId) {
-                EventId eventId = (EventId) o;
-
-                return Objects.equals(this.id, eventId.id);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(id);
-        }
-
-        @Override
-        public String toString() {
-            return MoreObjects.toStringHelper(this)
-                .add("id", id)
-                .toString();
-        }
-    }
-
-    User getUser();
-
-    boolean isNoop();
-
-    EventId getEventId();
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
deleted file mode 100644
index 98607f1..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ /dev/null
@@ -1,582 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.mailbox;
-
-import java.time.Instant;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-
-import org.apache.james.core.User;
-import org.apache.james.core.quota.QuotaCount;
-import org.apache.james.core.quota.QuotaSize;
-import org.apache.james.mailbox.acl.ACLDiff;
-import org.apache.james.mailbox.events.Group;
-import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.model.MessageMetaData;
-import org.apache.james.mailbox.model.Quota;
-import org.apache.james.mailbox.model.QuotaRoot;
-import org.apache.james.mailbox.model.UpdatedFlags;
-
-import com.github.steveash.guavate.Guavate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-
-/**
- * Listens to <code>Mailbox</code> events.<br>
- * Note that listeners may be removed asynchronously.
- */
-public interface MailboxListener {
-
-    interface GroupMailboxListener extends MailboxListener {
-        Group getDefaultGroup();
-    }
-
-    enum ExecutionMode {
-        SYNCHRONOUS,
-        ASYNCHRONOUS
-    }
-
-    default ExecutionMode getExecutionMode() {
-        return ExecutionMode.SYNCHRONOUS;
-    }
-
-    /**
-     * Informs this listener about the given event.
-     *
-     * @param event not null
-     */
-    void event(Event event) throws Exception;
-
-    interface QuotaEvent extends Event {
-        QuotaRoot getQuotaRoot();
-    }
-
-    class QuotaUsageUpdatedEvent implements QuotaEvent {
-        private final EventId eventId;
-        private final User user;
-        private final QuotaRoot quotaRoot;
-        private final Quota<QuotaCount> countQuota;
-        private final Quota<QuotaSize> sizeQuota;
-        private final Instant instant;
-
-        public QuotaUsageUpdatedEvent(EventId eventId, User user, QuotaRoot quotaRoot, Quota<QuotaCount> countQuota, Quota<QuotaSize> sizeQuota, Instant instant) {
-            this.eventId = eventId;
-            this.user = user;
-            this.quotaRoot = quotaRoot;
-            this.countQuota = countQuota;
-            this.sizeQuota = sizeQuota;
-            this.instant = instant;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return false;
-        }
-
-        @Override
-        public User getUser() {
-            return user;
-        }
-
-        public Quota<QuotaCount> getCountQuota() {
-            return countQuota;
-        }
-
-        public Quota<QuotaSize> getSizeQuota() {
-            return sizeQuota;
-        }
-
-        @Override
-        public QuotaRoot getQuotaRoot() {
-            return quotaRoot;
-        }
-
-        public Instant getInstant() {
-            return instant;
-        }
-
-        @Override
-        public EventId getEventId() {
-            return eventId;
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof QuotaUsageUpdatedEvent) {
-                QuotaUsageUpdatedEvent that = (QuotaUsageUpdatedEvent) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.quotaRoot, that.quotaRoot)
-                    && Objects.equals(this.countQuota, that.countQuota)
-                    && Objects.equals(this.sizeQuota, that.sizeQuota)
-                    && Objects.equals(this.instant, that.instant);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, user, quotaRoot, countQuota, sizeQuota, instant);
-        }
-
-    }
-
-    /**
-     * A mailbox event.
-     */
-    abstract class MailboxEvent implements Event {
-        protected final MailboxPath path;
-        protected final MailboxId mailboxId;
-        protected final User user;
-        protected final MailboxSession.SessionId sessionId;
-        protected final EventId eventId;
-
-        public MailboxEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
-            this.user = user;
-            this.path = path;
-            this.mailboxId = mailboxId;
-            this.sessionId = sessionId;
-            this.eventId = eventId;
-        }
-
-        /**
-         * Gets the {@link User} in which's context the {@link MailboxEvent}
-         * happened
-         *
-         * @return user
-         */
-        @Override
-        public User getUser() {
-            return user;
-        }
-
-        @Override
-        public EventId getEventId() {
-            return eventId;
-        }
-
-        /**
-         * Gets the sessionId in which's context the {@link MailboxEvent}
-         * happened
-         *
-         * @return sessionId
-         */
-        public MailboxSession.SessionId getSessionId() {
-            return sessionId;
-        }
-
-        /**
-         * Return the path of the Mailbox this event belongs to.
-         *
-         * @return path
-         */
-        public MailboxPath getMailboxPath() {
-            return path;
-        }
-
-        /**
-         * Return the id of the Mailbox this event belongs to.
-         *
-         * @return mailboxId
-         */
-        public MailboxId getMailboxId() {
-            return mailboxId;
-        }
-    }
-
-    /**
-     * Indicates that mailbox has been deleted.
-     */
-    class MailboxDeletion extends MailboxEvent {
-        private final QuotaRoot quotaRoot;
-        private final QuotaCount deletedMessageCount;
-        private final QuotaSize totalDeletedSize;
-
-        public MailboxDeletion(MailboxSession.SessionId sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize,
-                               MailboxId mailboxId, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-            this.quotaRoot = quotaRoot;
-            this.deletedMessageCount = deletedMessageCount;
-            this.totalDeletedSize = totalDeletedSize;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return false;
-        }
-
-        public QuotaRoot getQuotaRoot() {
-            return quotaRoot;
-        }
-
-        public QuotaCount getDeletedMessageCount() {
-            return deletedMessageCount;
-        }
-
-        public QuotaSize getTotalDeletedSize() {
-            return totalDeletedSize;
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof MailboxDeletion) {
-                MailboxDeletion that = (MailboxDeletion) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.mailboxId, that.mailboxId)
-                    && Objects.equals(this.quotaRoot, that.quotaRoot)
-                    && Objects.equals(this.deletedMessageCount, that.deletedMessageCount)
-                    && Objects.equals(this.totalDeletedSize, that.totalDeletedSize);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, mailboxId, quotaRoot, deletedMessageCount, totalDeletedSize);
-        }
-    }
-
-    /**
-     * Indicates that a mailbox has been Added.
-     */
-    class MailboxAdded extends MailboxEvent {
-
-        public MailboxAdded(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-        }
-
-        @Override
-        public boolean isNoop() {
-            return false;
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof MailboxAdded) {
-                MailboxAdded that = (MailboxAdded) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.mailboxId, that.mailboxId);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, mailboxId);
-        }
-    }
-
-    /**
-     * Indicates that a mailbox has been renamed.
-     */
-    class MailboxRenamed extends MailboxEvent {
-        private final MailboxPath newPath;
-
-        public MailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, MailboxPath newPath, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-            this.newPath = newPath;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return newPath.equals(path);
-        }
-
-        /**
-         * Gets the new name for this mailbox.
-         *
-         * @return name, not null
-         */
-        public MailboxPath getNewPath() {
-            return newPath;
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof MailboxRenamed) {
-                MailboxRenamed that = (MailboxRenamed) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.mailboxId, that.mailboxId)
-                    && Objects.equals(this.newPath, that.newPath);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, mailboxId, newPath);
-        }
-    }
-
-
-    /**
-     * A mailbox event related to updated ACL
-     */
-    class MailboxACLUpdated extends MailboxEvent {
-        private final ACLDiff aclDiff;
-
-        public MailboxACLUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-            this.aclDiff = aclDiff;
-        }
-
-        public ACLDiff getAclDiff() {
-            return aclDiff;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return aclDiff.getNewACL().equals(aclDiff.getOldACL());
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof MailboxACLUpdated) {
-                MailboxACLUpdated that = (MailboxACLUpdated) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.aclDiff, that.aclDiff)
-                    && Objects.equals(this.mailboxId, that.mailboxId);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, aclDiff, mailboxId);
-        }
-
-    }
-
-    /**
-     * A mailbox event related to a message.
-     */
-    abstract class MessageEvent extends MailboxEvent {
-
-        public MessageEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-        }
-
-        /**
-         * Gets the message UIDs for the subject of this event.
-         *
-         * @return message uids
-         */
-        public abstract Collection<MessageUid> getUids();
-    }
-
-    abstract class MetaDataHoldingEvent extends MessageEvent {
-
-        public MetaDataHoldingEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-        }
-
-        /**
-         * Return the flags which were set for the affected message
-         *
-         * @return flags
-         */
-        public abstract MessageMetaData getMetaData(MessageUid uid);
-
-    }
-
-    class Expunged extends MetaDataHoldingEvent {
-        private final Map<MessageUid, MessageMetaData> expunged;
-
-        public Expunged(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, Map<MessageUid, MessageMetaData> uids, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-            this.expunged = ImmutableMap.copyOf(uids);
-        }
-
-        @Override
-        public Collection<MessageUid> getUids() {
-            return expunged.keySet();
-        }
-
-        /**
-         * Return the flags which were set for the added message
-         *
-         * @return flags
-         */
-        @Override
-        public MessageMetaData getMetaData(MessageUid uid) {
-            return expunged.get(uid);
-        }
-
-        public Map<MessageUid, MessageMetaData> getExpunged() {
-            return expunged;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return expunged.isEmpty();
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof Expunged) {
-                Expunged that = (Expunged) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.mailboxId, that.mailboxId)
-                    && Objects.equals(this.expunged, that.expunged);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, mailboxId, expunged);
-        }
-    }
-
-    /**
-     * A mailbox event related to updated flags
-     */
-    class FlagsUpdated extends MessageEvent {
-        private final List<MessageUid> uids;
-        private final List<UpdatedFlags> updatedFlags;
-
-        public FlagsUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, List<UpdatedFlags> updatedFlags,
-                            EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-            this.updatedFlags = ImmutableList.copyOf(updatedFlags);
-            this.uids = updatedFlags.stream()
-                .map(UpdatedFlags::getUid)
-                .collect(Guavate.toImmutableList());
-        }
-
-        @Override
-        public Collection<MessageUid> getUids() {
-            return uids;
-        }
-
-        public List<UpdatedFlags> getUpdatedFlags() {
-            return updatedFlags;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return updatedFlags.isEmpty();
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof FlagsUpdated) {
-                FlagsUpdated that = (FlagsUpdated) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.mailboxId, that.mailboxId)
-                    && Objects.equals(this.uids, that.uids)
-                    && Objects.equals(this.updatedFlags, that.updatedFlags);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, mailboxId, uids, updatedFlags);
-        }
-    }
-
-    /**
-     * A mailbox event related to added message
-     */
-    class Added extends MetaDataHoldingEvent {
-        private final Map<MessageUid, MessageMetaData> added;
-
-        public Added(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId,
-                     SortedMap<MessageUid, MessageMetaData> uids, EventId eventId) {
-            super(sessionId, user, path, mailboxId, eventId);
-            this.added = ImmutableMap.copyOf(uids);
-        }
-
-        /**
-         * Return the flags which were set for the added message
-         *
-         * @return flags
-         */
-        public MessageMetaData getMetaData(MessageUid uid) {
-            return added.get(uid);
-        }
-
-        @Override
-        public Collection<MessageUid> getUids() {
-            return added.keySet();
-        }
-
-        public Map<MessageUid, MessageMetaData> getAdded() {
-            return added;
-        }
-
-        @Override
-        public boolean isNoop() {
-            return added.isEmpty();
-        }
-
-        @Override
-        public final boolean equals(Object o) {
-            if (o instanceof Added) {
-                Added that = (Added) o;
-
-                return Objects.equals(this.eventId, that.eventId)
-                    && Objects.equals(this.sessionId, that.sessionId)
-                    && Objects.equals(this.user, that.user)
-                    && Objects.equals(this.path, that.path)
-                    && Objects.equals(this.mailboxId, that.mailboxId)
-                    && Objects.equals(this.added, that.added);
-            }
-            return false;
-        }
-
-        @Override
-        public final int hashCode() {
-            return Objects.hash(eventId, sessionId, user, path, mailboxId, added);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
deleted file mode 100644
index 8b72378..0000000
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MessageMoveEvent.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox;
-
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.apache.james.core.User;
-import org.apache.james.mailbox.model.MailboxId;
-import org.apache.james.mailbox.model.MessageId;
-import org.apache.james.mailbox.model.MessageMoves;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-
-public class MessageMoveEvent implements Event {
-
-    public static Builder builder() {
-        return new Builder();
-    }
-
-    public static class Builder {
-        private ImmutableList.Builder<MessageId> messageIds;
-        private User user;
-        private MessageMoves messageMoves;
-        private Optional<EventId> eventId;
-
-        private Builder() {
-            messageIds = ImmutableList.builder();
-            eventId = Optional.empty();
-        }
-
-        public Builder session(MailboxSession session) {
-            this.user = session.getUser();
-            return this;
-        }
-
-        public Builder user(User user) {
-            this.user = user;
-            return this;
-        }
-
-        public Builder messageMoves(MessageMoves messageMoves) {
-            this.messageMoves = messageMoves;
-            return this;
-        }
-
-        public Builder messageId(MessageId messageId) {
-            this.messageIds.add(messageId);
-            return this;
-        }
-
-        public Builder eventId(EventId eventId) {
-            this.eventId = Optional.of(eventId);
-            return this;
-        }
-
-        public Builder messageId(Iterable<MessageId> messageIds) {
-            this.messageIds.addAll(messageIds);
-            return this;
-        }
-
-        public MessageMoveEvent build() {
-            Preconditions.checkNotNull(user, "'user' is mandatory");
-            Preconditions.checkNotNull(messageMoves, "'messageMoves' is mandatory");
-
-            return new MessageMoveEvent(eventId.orElse(EventId.random()), user, messageMoves, messageIds.build());
-        }
-    }
-
-    private final EventId eventId;
-    private final User user;
-    private final MessageMoves messageMoves;
-    private final Collection<MessageId> messageIds;
-
-    @VisibleForTesting
-    MessageMoveEvent(EventId eventId, User user, MessageMoves messageMoves, Collection<MessageId> messageIds) {
-        this.eventId = eventId;
-        this.user = user;
-        this.messageMoves = messageMoves;
-        this.messageIds = messageIds;
-    }
-
-    @Override
-    public boolean isNoop() {
-        return messageIds.isEmpty();
-    }
-
-    public Collection<MessageId> getMessageIds() {
-        return messageIds;
-    }
-
-    @Override
-    public EventId getEventId() {
-        return eventId;
-    }
-
-    @Override
-    public User getUser() {
-        return user;
-    }
-
-    public MessageMoves getMessageMoves() {
-        return messageMoves;
-    }
-
-    public boolean isMoveTo(MailboxId mailboxId) {
-        return messageMoves.addedMailboxIds()
-                .contains(mailboxId);
-    }
-
-    public boolean isMoveFrom(MailboxId mailboxId) {
-        return messageMoves.removedMailboxIds()
-                .contains(mailboxId);
-    }
-
-    @Override
-    public final boolean equals(Object o) {
-        if (o instanceof MessageMoveEvent) {
-            MessageMoveEvent that = (MessageMoveEvent) o;
-
-            return Objects.equals(this.eventId, that.eventId)
-                && Objects.equals(this.user, that.user)
-                && Objects.equals(this.messageMoves, that.messageMoves)
-                && Objects.equals(this.messageIds, that.messageIds);
-        }
-        return false;
-    }
-
-    @Override
-    public final int hashCode() {
-        return Objects.hash(eventId, user, messageMoves, messageIds);
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java
new file mode 100644
index 0000000..ff01b03
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/Event.java
@@ -0,0 +1,83 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.events;
+
+import java.util.Objects;
+import java.util.UUID;
+
+import org.apache.james.core.User;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
+
+public interface Event {
+
+    class EventId {
+        public static EventId of(UUID uuid) {
+            return new EventId(uuid);
+        }
+
+        public static EventId random() {
+            return new EventId(UUID.randomUUID());
+        }
+
+        public static EventId of(String serialized) {
+            return of(UUID.fromString(serialized));
+        }
+
+        private final UUID id;
+
+        private EventId(UUID id) {
+            Preconditions.checkNotNull(id);
+            this.id = id;
+        }
+
+        public UUID getId() {
+            return id;
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof EventId) {
+                EventId eventId = (EventId) o;
+
+                return Objects.equals(this.id, eventId.id);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(id);
+        }
+
+        @Override
+        public String toString() {
+            return MoreObjects.toStringHelper(this)
+                .add("id", id)
+                .toString();
+        }
+    }
+
+    User getUser();
+
+    boolean isNoop();
+
+    EventId getEventId();
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
index 2333736..0b319f7 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventBus.java
@@ -21,9 +21,6 @@ package org.apache.james.mailbox.events;
 
 import java.util.Set;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
-
 import com.google.common.collect.ImmutableSet;
 
 import reactor.core.publisher.Mono;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java
index 5c0057c..ed3dee5 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/EventDeadLetters.java
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.events;
 
-import org.apache.james.mailbox.Event;
-
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
new file mode 100644
index 0000000..dbd44cf
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
@@ -0,0 +1,583 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mailbox.events;
+
+import java.time.Instant;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedMap;
+
+import org.apache.james.core.User;
+import org.apache.james.core.quota.QuotaCount;
+import org.apache.james.core.quota.QuotaSize;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MessageMetaData;
+import org.apache.james.mailbox.model.Quota;
+import org.apache.james.mailbox.model.QuotaRoot;
+import org.apache.james.mailbox.model.UpdatedFlags;
+
+import com.github.steveash.guavate.Guavate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+
+/**
+ * Listens to <code>Mailbox</code> events.<br>
+ * Note that listeners may be removed asynchronously.
+ */
+public interface MailboxListener {
+
+    interface GroupMailboxListener extends MailboxListener {
+        Group getDefaultGroup();
+    }
+
+    enum ExecutionMode {
+        SYNCHRONOUS,
+        ASYNCHRONOUS
+    }
+
+    default ExecutionMode getExecutionMode() {
+        return ExecutionMode.SYNCHRONOUS;
+    }
+
+    /**
+     * Informs this listener about the given event.
+     *
+     * @param event not null
+     */
+    void event(Event event) throws Exception;
+
+    interface QuotaEvent extends Event {
+        QuotaRoot getQuotaRoot();
+    }
+
+    class QuotaUsageUpdatedEvent implements QuotaEvent {
+        private final EventId eventId;
+        private final User user;
+        private final QuotaRoot quotaRoot;
+        private final Quota<QuotaCount> countQuota;
+        private final Quota<QuotaSize> sizeQuota;
+        private final Instant instant;
+
+        public QuotaUsageUpdatedEvent(EventId eventId, User user, QuotaRoot quotaRoot, Quota<QuotaCount> countQuota, Quota<QuotaSize> sizeQuota, Instant instant) {
+            this.eventId = eventId;
+            this.user = user;
+            this.quotaRoot = quotaRoot;
+            this.countQuota = countQuota;
+            this.sizeQuota = sizeQuota;
+            this.instant = instant;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return false;
+        }
+
+        @Override
+        public User getUser() {
+            return user;
+        }
+
+        public Quota<QuotaCount> getCountQuota() {
+            return countQuota;
+        }
+
+        public Quota<QuotaSize> getSizeQuota() {
+            return sizeQuota;
+        }
+
+        @Override
+        public QuotaRoot getQuotaRoot() {
+            return quotaRoot;
+        }
+
+        public Instant getInstant() {
+            return instant;
+        }
+
+        @Override
+        public EventId getEventId() {
+            return eventId;
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof QuotaUsageUpdatedEvent) {
+                QuotaUsageUpdatedEvent that = (QuotaUsageUpdatedEvent) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.quotaRoot, that.quotaRoot)
+                    && Objects.equals(this.countQuota, that.countQuota)
+                    && Objects.equals(this.sizeQuota, that.sizeQuota)
+                    && Objects.equals(this.instant, that.instant);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, user, quotaRoot, countQuota, sizeQuota, instant);
+        }
+
+    }
+
+    /**
+     * A mailbox event.
+     */
+    abstract class MailboxEvent implements Event {
+        protected final MailboxPath path;
+        protected final MailboxId mailboxId;
+        protected final User user;
+        protected final MailboxSession.SessionId sessionId;
+        protected final EventId eventId;
+
+        public MailboxEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
+            this.user = user;
+            this.path = path;
+            this.mailboxId = mailboxId;
+            this.sessionId = sessionId;
+            this.eventId = eventId;
+        }
+
+        /**
+         * Gets the {@link User} in which's context the {@link MailboxEvent}
+         * happened
+         *
+         * @return user
+         */
+        @Override
+        public User getUser() {
+            return user;
+        }
+
+        @Override
+        public EventId getEventId() {
+            return eventId;
+        }
+
+        /**
+         * Gets the sessionId in which's context the {@link MailboxEvent}
+         * happened
+         *
+         * @return sessionId
+         */
+        public MailboxSession.SessionId getSessionId() {
+            return sessionId;
+        }
+
+        /**
+         * Return the path of the Mailbox this event belongs to.
+         *
+         * @return path
+         */
+        public MailboxPath getMailboxPath() {
+            return path;
+        }
+
+        /**
+         * Return the id of the Mailbox this event belongs to.
+         *
+         * @return mailboxId
+         */
+        public MailboxId getMailboxId() {
+            return mailboxId;
+        }
+    }
+
+    /**
+     * Indicates that mailbox has been deleted.
+     */
+    class MailboxDeletion extends MailboxEvent {
+        private final QuotaRoot quotaRoot;
+        private final QuotaCount deletedMessageCount;
+        private final QuotaSize totalDeletedSize;
+
+        public MailboxDeletion(MailboxSession.SessionId sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize,
+                               MailboxId mailboxId, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+            this.quotaRoot = quotaRoot;
+            this.deletedMessageCount = deletedMessageCount;
+            this.totalDeletedSize = totalDeletedSize;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return false;
+        }
+
+        public QuotaRoot getQuotaRoot() {
+            return quotaRoot;
+        }
+
+        public QuotaCount getDeletedMessageCount() {
+            return deletedMessageCount;
+        }
+
+        public QuotaSize getTotalDeletedSize() {
+            return totalDeletedSize;
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof MailboxDeletion) {
+                MailboxDeletion that = (MailboxDeletion) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.mailboxId, that.mailboxId)
+                    && Objects.equals(this.quotaRoot, that.quotaRoot)
+                    && Objects.equals(this.deletedMessageCount, that.deletedMessageCount)
+                    && Objects.equals(this.totalDeletedSize, that.totalDeletedSize);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, mailboxId, quotaRoot, deletedMessageCount, totalDeletedSize);
+        }
+    }
+
+    /**
+     * Indicates that a mailbox has been Added.
+     */
+    class MailboxAdded extends MailboxEvent {
+
+        public MailboxAdded(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+        }
+
+        @Override
+        public boolean isNoop() {
+            return false;
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof MailboxAdded) {
+                MailboxAdded that = (MailboxAdded) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.mailboxId, that.mailboxId);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, mailboxId);
+        }
+    }
+
+    /**
+     * Indicates that a mailbox has been renamed.
+     */
+    class MailboxRenamed extends MailboxEvent {
+        private final MailboxPath newPath;
+
+        public MailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, MailboxPath newPath, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+            this.newPath = newPath;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return newPath.equals(path);
+        }
+
+        /**
+         * Gets the new name for this mailbox.
+         *
+         * @return name, not null
+         */
+        public MailboxPath getNewPath() {
+            return newPath;
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof MailboxRenamed) {
+                MailboxRenamed that = (MailboxRenamed) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.mailboxId, that.mailboxId)
+                    && Objects.equals(this.newPath, that.newPath);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, mailboxId, newPath);
+        }
+    }
+
+
+    /**
+     * A mailbox event related to updated ACL
+     */
+    class MailboxACLUpdated extends MailboxEvent {
+        private final ACLDiff aclDiff;
+
+        public MailboxACLUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+            this.aclDiff = aclDiff;
+        }
+
+        public ACLDiff getAclDiff() {
+            return aclDiff;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return aclDiff.getNewACL().equals(aclDiff.getOldACL());
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof MailboxACLUpdated) {
+                MailboxACLUpdated that = (MailboxACLUpdated) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.aclDiff, that.aclDiff)
+                    && Objects.equals(this.mailboxId, that.mailboxId);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, aclDiff, mailboxId);
+        }
+
+    }
+
+    /**
+     * A mailbox event related to a message.
+     */
+    abstract class MessageEvent extends MailboxEvent {
+
+        public MessageEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+        }
+
+        /**
+         * Gets the message UIDs for the subject of this event.
+         *
+         * @return message uids
+         */
+        public abstract Collection<MessageUid> getUids();
+    }
+
+    abstract class MetaDataHoldingEvent extends MessageEvent {
+
+        public MetaDataHoldingEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+        }
+
+        /**
+         * Return the flags which were set for the affected message
+         *
+         * @return flags
+         */
+        public abstract MessageMetaData getMetaData(MessageUid uid);
+
+    }
+
+    class Expunged extends MetaDataHoldingEvent {
+        private final Map<MessageUid, MessageMetaData> expunged;
+
+        public Expunged(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, Map<MessageUid, MessageMetaData> uids, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+            this.expunged = ImmutableMap.copyOf(uids);
+        }
+
+        @Override
+        public Collection<MessageUid> getUids() {
+            return expunged.keySet();
+        }
+
+        /**
+         * Return the flags which were set for the added message
+         *
+         * @return flags
+         */
+        @Override
+        public MessageMetaData getMetaData(MessageUid uid) {
+            return expunged.get(uid);
+        }
+
+        public Map<MessageUid, MessageMetaData> getExpunged() {
+            return expunged;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return expunged.isEmpty();
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof Expunged) {
+                Expunged that = (Expunged) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.mailboxId, that.mailboxId)
+                    && Objects.equals(this.expunged, that.expunged);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, mailboxId, expunged);
+        }
+    }
+
+    /**
+     * A mailbox event related to updated flags
+     */
+    class FlagsUpdated extends MessageEvent {
+        private final List<MessageUid> uids;
+        private final List<UpdatedFlags> updatedFlags;
+
+        public FlagsUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId, List<UpdatedFlags> updatedFlags,
+                            EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+            this.updatedFlags = ImmutableList.copyOf(updatedFlags);
+            this.uids = updatedFlags.stream()
+                .map(UpdatedFlags::getUid)
+                .collect(Guavate.toImmutableList());
+        }
+
+        @Override
+        public Collection<MessageUid> getUids() {
+            return uids;
+        }
+
+        public List<UpdatedFlags> getUpdatedFlags() {
+            return updatedFlags;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return updatedFlags.isEmpty();
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof FlagsUpdated) {
+                FlagsUpdated that = (FlagsUpdated) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.mailboxId, that.mailboxId)
+                    && Objects.equals(this.uids, that.uids)
+                    && Objects.equals(this.updatedFlags, that.updatedFlags);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, mailboxId, uids, updatedFlags);
+        }
+    }
+
+    /**
+     * A mailbox event related to added message
+     */
+    class Added extends MetaDataHoldingEvent {
+        private final Map<MessageUid, MessageMetaData> added;
+
+        public Added(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId,
+                     SortedMap<MessageUid, MessageMetaData> uids, EventId eventId) {
+            super(sessionId, user, path, mailboxId, eventId);
+            this.added = ImmutableMap.copyOf(uids);
+        }
+
+        /**
+         * Return the flags which were set for the added message
+         *
+         * @return flags
+         */
+        public MessageMetaData getMetaData(MessageUid uid) {
+            return added.get(uid);
+        }
+
+        @Override
+        public Collection<MessageUid> getUids() {
+            return added.keySet();
+        }
+
+        public Map<MessageUid, MessageMetaData> getAdded() {
+            return added;
+        }
+
+        @Override
+        public boolean isNoop() {
+            return added.isEmpty();
+        }
+
+        @Override
+        public final boolean equals(Object o) {
+            if (o instanceof Added) {
+                Added that = (Added) o;
+
+                return Objects.equals(this.eventId, that.eventId)
+                    && Objects.equals(this.sessionId, that.sessionId)
+                    && Objects.equals(this.user, that.user)
+                    && Objects.equals(this.path, that.path)
+                    && Objects.equals(this.mailboxId, that.mailboxId)
+                    && Objects.equals(this.added, that.added);
+            }
+            return false;
+        }
+
+        @Override
+        public final int hashCode() {
+            return Objects.hash(eventId, sessionId, user, path, mailboxId, added);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java
new file mode 100644
index 0000000..494f9ae
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MessageMoveEvent.java
@@ -0,0 +1,153 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.events;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Optional;
+
+import org.apache.james.core.User;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.model.MessageMoves;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+public class MessageMoveEvent implements Event {
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private ImmutableList.Builder<MessageId> messageIds;
+        private User user;
+        private MessageMoves messageMoves;
+        private Optional<EventId> eventId;
+
+        private Builder() {
+            messageIds = ImmutableList.builder();
+            eventId = Optional.empty();
+        }
+
+        public Builder session(MailboxSession session) {
+            this.user = session.getUser();
+            return this;
+        }
+
+        public Builder user(User user) {
+            this.user = user;
+            return this;
+        }
+
+        public Builder messageMoves(MessageMoves messageMoves) {
+            this.messageMoves = messageMoves;
+            return this;
+        }
+
+        public Builder messageId(MessageId messageId) {
+            this.messageIds.add(messageId);
+            return this;
+        }
+
+        public Builder eventId(EventId eventId) {
+            this.eventId = Optional.of(eventId);
+            return this;
+        }
+
+        public Builder messageId(Iterable<MessageId> messageIds) {
+            this.messageIds.addAll(messageIds);
+            return this;
+        }
+
+        public MessageMoveEvent build() {
+            Preconditions.checkNotNull(user, "'user' is mandatory");
+            Preconditions.checkNotNull(messageMoves, "'messageMoves' is mandatory");
+
+            return new MessageMoveEvent(eventId.orElse(EventId.random()), user, messageMoves, messageIds.build());
+        }
+    }
+
+    private final EventId eventId;
+    private final User user;
+    private final MessageMoves messageMoves;
+    private final Collection<MessageId> messageIds;
+
+    @VisibleForTesting
+    MessageMoveEvent(EventId eventId, User user, MessageMoves messageMoves, Collection<MessageId> messageIds) {
+        this.eventId = eventId;
+        this.user = user;
+        this.messageMoves = messageMoves;
+        this.messageIds = messageIds;
+    }
+
+    @Override
+    public boolean isNoop() {
+        return messageIds.isEmpty();
+    }
+
+    public Collection<MessageId> getMessageIds() {
+        return messageIds;
+    }
+
+    @Override
+    public EventId getEventId() {
+        return eventId;
+    }
+
+    @Override
+    public User getUser() {
+        return user;
+    }
+
+    public MessageMoves getMessageMoves() {
+        return messageMoves;
+    }
+
+    public boolean isMoveTo(MailboxId mailboxId) {
+        return messageMoves.addedMailboxIds()
+                .contains(mailboxId);
+    }
+
+    public boolean isMoveFrom(MailboxId mailboxId) {
+        return messageMoves.removedMailboxIds()
+                .contains(mailboxId);
+    }
+
+    @Override
+    public final boolean equals(Object o) {
+        if (o instanceof MessageMoveEvent) {
+            MessageMoveEvent that = (MessageMoveEvent) o;
+
+            return Objects.equals(this.eventId, that.eventId)
+                && Objects.equals(this.user, that.user)
+                && Objects.equals(this.messageMoves, that.messageMoves)
+                && Objects.equals(this.messageIds, that.messageIds);
+        }
+        return false;
+    }
+
+    @Override
+    public final int hashCode() {
+        return Objects.hash(eventId, user, messageMoves, messageIds);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
index 62e6399..94530c6 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/EventTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.UUID;
 
+import org.apache.james.mailbox.events.Event;
 import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
index 9db71ba..57957ac 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
@@ -32,6 +32,8 @@ import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.events.Event;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
index 12dcce1..97e0103 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerStressTest.java
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 8a3d351..9681936 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -37,6 +37,8 @@ import org.apache.james.mailbox.MailboxManager.MailboxCapabilities;
 import org.apache.james.mailbox.MessageManager.AppendCommand;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.events.MailboxListener;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.exception.AnnotationException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.TooLongMailboxNameException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
index db85d82..ad422d8 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MessageMoveEventTest.java
@@ -22,8 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MailboxSessionUtil;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.apache.james.mailbox.model.MessageMoves;
 import org.apache.james.mailbox.model.TestId;
 import org.apache.james.mailbox.model.TestMessageId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
index be4b7ef..3bc1304 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/ErrorHandlingContract.java
@@ -36,8 +36,6 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.util.EventCollector;
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
index e93c96c..798d765 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventBusTestFixture.java
@@ -27,8 +27,6 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java
index e2282a1..aef0100 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/EventDeadLettersContract.java
@@ -31,8 +31,6 @@ import java.util.stream.IntStream;
 import java.util.stream.Stream;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
index 159094b..491fa88 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/GroupContract.java
@@ -43,8 +43,6 @@ import static org.mockito.Mockito.when;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
index 26ece3b..b457e6d 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/events/KeyContract.java
@@ -45,8 +45,6 @@ import java.time.Duration;
 import java.util.concurrent.CountDownLatch;
 
 import org.apache.james.core.User;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.TestId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
index 3a76147..8787db5 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MessageMovesTest.java
@@ -19,7 +19,7 @@
 
 package org.apache.james.mailbox.model;
 
-import org.apache.james.mailbox.MessageMoveEvent;
+import org.apache.james.mailbox.events.MessageMoveEvent;
 import org.junit.jupiter.api.Test;
 
 import nl.jqno.equalsverifier.EqualsVerifier;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java b/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
index f2f3c42..392cc95 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/util/EventCollector.java
@@ -22,9 +22,9 @@ package org.apache.james.mailbox.util;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 
 public class EventCollector implements MailboxListener.GroupMailboxListener {
     private static class EventCollectorGroup extends Group {}

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
index e3f38c8..7e39cc0 100644
--- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
+++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
@@ -1,9 +1,9 @@
 package org.apache.james.mailbox.caching;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java
index 660a748..26537a3 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/MailboxOperationLoggingListener.java
@@ -23,9 +23,9 @@ import static org.apache.james.mailbox.cassandra.GhostMailbox.MAILBOX_ID;
 import static org.apache.james.mailbox.cassandra.GhostMailbox.MAILBOX_NAME;
 import static org.apache.james.mailbox.cassandra.GhostMailbox.TYPE;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 
 /**
  * See https://issues.apache.org/jira/browse/MAILBOX-322 for reading about the Ghost mailbox bug.

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java
index 5da4adb..ae58755 100644
--- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/InVMEventBus.java
@@ -24,8 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import javax.inject.Inject;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.events.delivery.EventDelivery;
 import org.apache.james.mailbox.events.delivery.EventDelivery.PermanentFailureHandler.StoreToDeadLetters;
 import org.apache.james.mailbox.events.delivery.EventDelivery.Retryer.BackoffRetryer;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java
index 122763a..45fff05 100644
--- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/MemoryEventDeadLetters.java
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.events;
 
-import org.apache.james.mailbox.Event;
-
 import com.google.common.base.Preconditions;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
index e34cb31..c30a709 100644
--- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
@@ -24,10 +24,10 @@ import static org.apache.james.mailbox.events.delivery.EventDelivery.Retryer.NO_
 
 import java.time.Duration;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventDeadLetters;
 import org.apache.james.mailbox.events.Group;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.RetryBackoffConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
index f0b1b1e..6cdbe28 100644
--- a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/InVmEventDelivery.java
@@ -25,9 +25,9 @@ import java.io.Closeable;
 
 import javax.inject.Inject;
 
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.Event;
 import org.apache.james.mailbox.events.EventBus;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.metrics.api.TimeMetric;
 import org.apache.james.util.MDCBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
index dc122f6..08d22c9 100644
--- a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
+++ b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/InVmEventDeliveryTest.java
@@ -31,7 +31,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
-import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.events.MailboxListener;
 import org.apache.james.mailbox.events.MemoryEventDeadLetters;
 import org.apache.james.mailbox.events.RetryBackoffConfiguration;
 import org.apache.james.mailbox.events.delivery.EventDelivery.DeliveryOption;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java
index f1cc7d3..e6f6e1d 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/EventDispatcher.java
@@ -29,8 +29,6 @@ import java.util.Set;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.event.json.EventSerializer;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.util.MDCBuilder;
 import org.apache.james.util.MDCStructuredLogger;
 import org.apache.james.util.StructuredLogger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java
index 9171436..1087d9a 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupConsumerRetry.java
@@ -25,7 +25,6 @@ import static org.apache.james.backend.rabbitmq.Constants.EMPTY_ROUTING_KEY;
 import static org.apache.james.mailbox.events.GroupRegistration.RETRY_COUNT;
 import static org.apache.james.mailbox.events.RabbitMQEventBus.MAILBOX_EVENT;
 
-import org.apache.james.mailbox.Event;
 import org.apache.james.util.MDCStructuredLogger;
 import org.apache.james.util.StructuredLogger;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
index 5a9bdf0..426ae46 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistration.java
@@ -32,8 +32,6 @@ import java.util.Objects;
 import java.util.Optional;
 
 import org.apache.james.event.json.EventSerializer;
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.util.MDCBuilder;
 
 import com.github.fge.lambdas.Throwing;

http://git-wip-us.apache.org/repos/asf/james-project/blob/df5d678c/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java
index 1950aab..05f4e09 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/GroupRegistrationHandler.java
@@ -23,7 +23,6 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.james.event.json.EventSerializer;
-import org.apache.james.mailbox.MailboxListener;
 
 import com.rabbitmq.client.Connection;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[04/10] james-project git commit: MAILBOX-374 Our connection mono should cache the connection as long as it is open

Posted by bt...@apache.org.
MAILBOX-374 Our connection mono should cache the connection as long as it is open

We should regenerate the connection mono when the connection had been close,
for instance due to error.

A custom callable had been written as I miss a `Mono<T>.cacheWhen(Predicate<T>)`


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/edf85300
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/edf85300
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/edf85300

Branch: refs/heads/master
Commit: edf85300021eafd1ed1ef944d291c18bcfd9d996
Parents: 603de62
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 14:13:56 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:33:25 2019 +0700

----------------------------------------------------------------------
 .../rabbitmq/RabbitMQConnectionFactory.java     | 32 ++++++++++++++++----
 .../james/mailbox/events/RabbitMQEventBus.java  |  6 ++--
 2 files changed, 30 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/edf85300/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
index e02fb28..c13b21b 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
@@ -19,6 +19,8 @@
 package org.apache.james.backend.rabbitmq;
 
 import java.time.Duration;
+import java.util.Optional;
+import java.util.concurrent.Callable;
 
 import javax.inject.Inject;
 
@@ -29,16 +31,34 @@ import reactor.core.publisher.Mono;
 import reactor.core.scheduler.Schedulers;
 
 public class RabbitMQConnectionFactory {
+    private class ConnectionCallable implements Callable<Connection> {
+        private final ConnectionFactory connectionFactory;
+        private Optional<Connection> connection;
+
+        ConnectionCallable(ConnectionFactory connectionFactory) {
+            this.connectionFactory = connectionFactory;
+            connection = Optional.empty();
+        }
+
+        @Override
+        public Connection call() throws Exception {
+            if (connection.map(Connection::isOpen).orElse(false)) {
+                return connection.get();
+            }
+            Connection newConnection = connectionFactory.newConnection();
+            connection = Optional.of(newConnection);
+            return newConnection;
+        }
+    }
+
     private final ConnectionFactory connectionFactory;
 
-    private final int maxRetries;
-    private final int minDelay;
+    private final RabbitMQConfiguration configuration;
 
     @Inject
     public RabbitMQConnectionFactory(RabbitMQConfiguration rabbitMQConfiguration) {
         this.connectionFactory = from(rabbitMQConfiguration);
-        this.maxRetries = rabbitMQConfiguration.getMaxRetries();
-        this.minDelay = rabbitMQConfiguration.getMinDelay();
+        this.configuration = rabbitMQConfiguration;
     }
 
     private ConnectionFactory from(RabbitMQConfiguration rabbitMQConfiguration) {
@@ -56,8 +76,8 @@ public class RabbitMQConnectionFactory {
     }
 
     public Mono<Connection> connectionMono() {
-        return Mono.fromCallable(connectionFactory::newConnection)
-            .retryBackoff(maxRetries, Duration.ofMillis(minDelay))
+        return Mono.fromCallable(new ConnectionCallable(connectionFactory))
+            .retryBackoff(configuration.getMaxRetries(), Duration.ofMillis(configuration.getMinDelay()))
             .publishOn(Schedulers.elastic());
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/edf85300/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
index b203032..ecfeb0b 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/RabbitMQEventBus.java
@@ -31,6 +31,7 @@ import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.metrics.api.MetricFactory;
 
+import com.github.fge.lambdas.Throwing;
 import com.rabbitmq.client.Connection;
 
 import reactor.core.publisher.Mono;
@@ -64,7 +65,7 @@ public class RabbitMQEventBus implements EventBus {
                      EventDeadLetters eventDeadLetters, MetricFactory metricFactory) {
         this.mailboxListenerExecutor = new MailboxListenerExecutor(metricFactory);
         this.eventBusId = EventBusId.random();
-        this.connectionMono = Mono.fromSupplier(rabbitMQConnectionFactory::create).cache();
+        this.connectionMono = rabbitMQConnectionFactory.connectionMono();
         this.eventSerializer = eventSerializer;
         this.routingKeyConverter = routingKeyConverter;
         this.retryBackoff = retryBackoff;
@@ -74,7 +75,8 @@ public class RabbitMQEventBus implements EventBus {
 
     public void start() {
         if (!isRunning.get()) {
-            sender = RabbitFlux.createSender(new SenderOptions().connectionMono(connectionMono));
+            sender = RabbitFlux.createSender(new SenderOptions().connectionMono(connectionMono)
+                .resourceManagementChannelMono(connectionMono.map(Throwing.function(Connection::createChannel))));
             MailboxListenerRegistry mailboxListenerRegistry = new MailboxListenerRegistry();
             keyRegistrationHandler = new KeyRegistrationHandler(eventBusId, eventSerializer, sender, connectionMono, routingKeyConverter, mailboxListenerRegistry, mailboxListenerExecutor);
             groupRegistrationHandler = new GroupRegistrationHandler(eventSerializer, sender, connectionMono, retryBackoff, eventDeadLetters, mailboxListenerExecutor);


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[08/10] james-project git commit: MAILBOX-374 Also test EventBus behaviour when confronted with RabbitMQ restarts

Posted by bt...@apache.org.
MAILBOX-374 Also test EventBus behaviour when confronted with RabbitMQ restarts


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/aa452a1f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/aa452a1f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/aa452a1f

Branch: refs/heads/master
Commit: aa452a1f7be7a1f616a8d0bf14a3d1273945d1c3
Parents: 7ab8c67
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 16:27:36 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:33:25 2019 +0700

----------------------------------------------------------------------
 .../mailbox/events/RabbitMQEventBusTest.java    | 50 ++++++++++++++++++++
 1 file changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/aa452a1f/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
index 2137610..38ca6c5 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
@@ -324,6 +324,56 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
             }
 
             @Test
+            void dispatchShouldWorkAfterRestartForOldRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+                eventBus.register(listener, GROUP_A);
+
+                rabbitMQExtension.getRabbitMQ().restart();
+
+                eventBus.dispatch(EVENT, NO_KEYS).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
+            void dispatchShouldWorkAfterRestartForNewRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+
+                rabbitMQExtension.getRabbitMQ().restart();
+
+                eventBus.register(listener, GROUP_A);
+
+                eventBus.dispatch(EVENT, NO_KEYS).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
+            void dispatchShouldWorkAfterRestartForOldKeyRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+                eventBus.register(listener, KEY_1);
+
+                rabbitMQExtension.getRabbitMQ().restart();
+
+                eventBus.dispatch(EVENT, KEY_1).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
+            void dispatchShouldWorkAfterRestartForNewKeyRegistration() throws Exception {
+                eventBus.start();
+                MailboxListener listener = newListener();
+
+                rabbitMQExtension.getRabbitMQ().restart();
+
+                eventBus.register(listener, KEY_1);
+
+                eventBus.dispatch(EVENT, KEY_1).block();
+                verify(listener, after(THIRTY_SECONDS).times(1)).event(EVENT);
+            }
+
+            @Test
             void dispatchShouldWorkAfterNetworkIssuesForNewRegistration() throws Exception {
                 eventBus.start();
                 MailboxListener listener = newListener();


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[07/10] james-project git commit: MAILBOX-374 Avoid a race condition upon connection recovery

Posted by bt...@apache.org.
MAILBOX-374 Avoid a race condition upon connection recovery

This will lead to multiple connection opening, waisting resources


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4270f4f7
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4270f4f7
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4270f4f7

Branch: refs/heads/master
Commit: 4270f4f7bb5288895b9cba3eaf143fcef506174e
Parents: e255eae
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 22:38:12 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:33:25 2019 +0700

----------------------------------------------------------------------
 .../apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/4270f4f7/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
index ac469e4..151e983 100644
--- a/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
+++ b/backends-common/rabbitmq/src/main/java/org/apache/james/backend/rabbitmq/RabbitMQConnectionFactory.java
@@ -41,7 +41,7 @@ public class RabbitMQConnectionFactory {
         }
 
         @Override
-        public Connection call() throws Exception {
+        public synchronized Connection call() throws Exception {
             if (connection.map(Connection::isOpen).orElse(false)) {
                 return connection.get();
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[06/10] james-project git commit: MAILBOX-374 Turn off exclusive - auto-deletes queues

Posted by bt...@apache.org.
MAILBOX-374 Turn off exclusive - auto-deletes queues

In the face of network errors, we can not achieve a 'safety' and 'liveness' property.

 - 'liveness': A James node that is not failmed always have its Key registration queue
 - 'safety': The "key registration queue" gets deleted when there is not more consumer.

If the network partition exceeded the configured heartbeat, then the queue is going to be deleted and James is going to fail (as its queue disapeared).

We choose the safer option of not having RabbitMQ responsible of automatic queue deletion. The admin is going to be responsible of queue cleanup after crash.


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/7ab8c67e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/7ab8c67e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/7ab8c67e

Branch: refs/heads/master
Commit: 7ab8c67e4804dce703786d1545ebcb8c92378a1d
Parents: c1a2a95
Author: Benoit Tellier <bt...@linagora.com>
Authored: Thu Jan 24 15:46:18 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Jan 25 10:33:25 2019 +0700

----------------------------------------------------------------------
 .../apache/james/mailbox/events/KeyRegistrationHandler.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7ab8c67e/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
index 6e84254..d8418be 100644
--- a/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
+++ b/mailbox/event/event-rabbitmq/src/main/java/org/apache/james/mailbox/events/KeyRegistrationHandler.java
@@ -78,10 +78,10 @@ class KeyRegistrationHandler {
     }
 
     void start() {
-        sender.declareQueue(QueueSpecification.queue()
+        sender.declareQueue(QueueSpecification.queue(eventBusId.asString())
             .durable(DURABLE)
-            .exclusive(EXCLUSIVE)
-            .autoDelete(AUTO_DELETE)
+            .exclusive(!EXCLUSIVE)
+            .autoDelete(!AUTO_DELETE)
             .arguments(NO_ARGUMENTS))
             .map(AMQP.Queue.DeclareOk::getQueue)
             .doOnSuccess(registrationQueue::initialize)


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org