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 2018/12/14 10:34:23 UTC

[07/18] james-project git commit: MAILBOX-364 Move EventDelivery class to event-memory module

MAILBOX-364 Move EventDelivery class to event-memory module


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

Branch: refs/heads/master
Commit: e0f830ce5e8f2685a55e167238350b4de61274b9
Parents: a972124
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Dec 12 10:30:31 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Dec 14 17:09:20 2018 +0700

----------------------------------------------------------------------
 mailbox/event/event-memory/pom.xml              | 77 +++++++++++++++++
 .../delivery/AsynchronousEventDelivery.java     | 51 ++++++++++++
 .../mailbox/events/delivery/EventDelivery.java  | 29 +++++++
 .../events/delivery/MixedEventDelivery.java     | 52 ++++++++++++
 .../delivery/SynchronousEventDelivery.java      | 55 +++++++++++++
 .../delivery/AsynchronousEventDeliveryTest.java | 83 +++++++++++++++++++
 .../events/delivery/MixedEventDeliveryTest.java | 86 +++++++++++++++++++
 .../delivery/SynchronousEventDeliveryTest.java  | 60 ++++++++++++++
 mailbox/pom.xml                                 |  1 +
 .../resources/META-INF/spring/event-system.xml  |  6 +-
 mailbox/store/pom.xml                           |  4 +
 .../store/event/AsynchronousEventDelivery.java  | 52 ------------
 .../mailbox/store/event/EventDelivery.java      | 29 -------
 .../mailbox/store/event/MixedEventDelivery.java | 52 ------------
 .../store/event/SynchronousEventDelivery.java   | 55 -------------
 .../event/AsynchronousEventDeliveryTest.java    | 83 -------------------
 .../store/event/MixedEventDeliveryTest.java     | 87 --------------------
 .../event/SynchronousEventDeliveryTest.java     | 60 --------------
 pom.xml                                         |  5 ++
 .../modules/mailbox/DefaultEventModule.java     |  8 +-
 20 files changed, 510 insertions(+), 425 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/pom.xml b/mailbox/event/event-memory/pom.xml
new file mode 100644
index 0000000..4047591
--- /dev/null
+++ b/mailbox/event/event-memory/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <artifactId>apache-james-mailbox</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.3.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>apache-james-mailbox-event-memory</artifactId>
+    <name>Apache James :: Mailbox :: Event :: In VM implementation</name>
+    <description>Memory implementation for the eventbus API</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-api</artifactId>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>metrics-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.vintage</groupId>
+            <artifactId>junit-vintage-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDelivery.java
new file mode 100644
index 0000000..028436c
--- /dev/null
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDelivery.java
@@ -0,0 +1,51 @@
+/****************************************************************
+ * 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.delivery;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+import javax.annotation.PreDestroy;
+
+import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.util.concurrent.NamedThreadFactory;
+
+public class AsynchronousEventDelivery implements EventDelivery {
+    private final ExecutorService threadPoolExecutor;
+    private final SynchronousEventDelivery synchronousEventDelivery;
+
+    public AsynchronousEventDelivery(int threadPoolSize, SynchronousEventDelivery synchronousEventDelivery) {
+        ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
+        this.threadPoolExecutor = Executors.newFixedThreadPool(threadPoolSize, threadFactory);
+        this.synchronousEventDelivery = synchronousEventDelivery;
+    }
+
+    @Override
+    public void deliver(MailboxListener mailboxListener, Event event) {
+        threadPoolExecutor.submit(() -> synchronousEventDelivery.deliver(mailboxListener, event));
+    }
+
+    @PreDestroy
+    public void stop() {
+        threadPoolExecutor.shutdownNow();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/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
new file mode 100644
index 0000000..56481e7
--- /dev/null
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/EventDelivery.java
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.delivery;
+
+import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.MailboxListener;
+
+public interface EventDelivery {
+
+    void deliver(MailboxListener mailboxListener, Event event);
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/MixedEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/MixedEventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/MixedEventDelivery.java
new file mode 100644
index 0000000..f8df0e5
--- /dev/null
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/MixedEventDelivery.java
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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.delivery;
+
+import javax.annotation.PreDestroy;
+
+import org.apache.james.mailbox.Event;
+import org.apache.james.mailbox.MailboxListener;
+
+public class MixedEventDelivery implements EventDelivery {
+
+    private final AsynchronousEventDelivery asynchronousEventDelivery;
+    private final SynchronousEventDelivery synchronousEventDelivery;
+
+    public MixedEventDelivery(AsynchronousEventDelivery asynchronousEventDelivery,
+                              SynchronousEventDelivery synchronousEventDelivery) {
+        this.asynchronousEventDelivery = asynchronousEventDelivery;
+        this.synchronousEventDelivery = synchronousEventDelivery;
+    }
+
+    @Override
+    public void deliver(MailboxListener mailboxListener, Event event) {
+        if (mailboxListener.getExecutionMode().equals(MailboxListener.ExecutionMode.SYNCHRONOUS)) {
+            synchronousEventDelivery.deliver(mailboxListener, event);
+        } else {
+            asynchronousEventDelivery.deliver(mailboxListener, event);
+        }
+    }
+
+    @PreDestroy
+    public void stop() {
+        asynchronousEventDelivery.stop();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/SynchronousEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/SynchronousEventDelivery.java b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/SynchronousEventDelivery.java
new file mode 100644
index 0000000..77e735d
--- /dev/null
+++ b/mailbox/event/event-memory/src/main/java/org/apache/james/mailbox/events/delivery/SynchronousEventDelivery.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.delivery;
+
+import javax.inject.Inject;
+
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SynchronousEventDelivery implements EventDelivery {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(SynchronousEventDelivery.class);
+
+    private final MetricFactory metricFactory;
+
+    @Inject
+    public SynchronousEventDelivery(MetricFactory metricFactory) {
+        this.metricFactory = metricFactory;
+    }
+
+    @Override
+    public void deliver(MailboxListener mailboxListener, Event event) {
+        TimeMetric timer = metricFactory.timer("mailbox-listener-" + mailboxListener.getClass().getSimpleName());
+        try {
+            mailboxListener.event(event);
+        } catch (Throwable throwable) {
+            LOGGER.error("Error while processing listener {} for {}",
+                    mailboxListener.getClass().getCanonicalName(), event.getClass().getCanonicalName(),
+                    throwable);
+        } finally {
+            timer.stopAndPublish();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDeliveryTest.java b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDeliveryTest.java
new file mode 100644
index 0000000..7a806e2
--- /dev/null
+++ b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/AsynchronousEventDeliveryTest.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.delivery;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.metrics.api.NoopMetricFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class AsynchronousEventDeliveryTest {
+
+    private static final int ONE_MINUTE = (int) TimeUnit.MINUTES.toMillis(1);
+    private MailboxListener mailboxListener;
+    private AsynchronousEventDelivery asynchronousEventDelivery;
+
+    @Before
+    public void setUp() {
+        mailboxListener = mock(MailboxListener.class);
+        asynchronousEventDelivery = new AsynchronousEventDelivery(2,
+            new SynchronousEventDelivery(new NoopMetricFactory()));
+    }
+
+    @After
+    public void tearDown() {
+        asynchronousEventDelivery.stop();
+    }
+
+    @Test
+    public void deliverShouldWork() {
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
+        asynchronousEventDelivery.deliver(mailboxListener, event);
+        verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
+    }
+
+    @Test
+    public void deliverShouldNotPropagateException() {
+        MockMailboxSession session = new MockMailboxSession("test");
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(),
+            session.getUser().getCoreUser(), null, null) {};
+        doThrow(new RuntimeException()).when(mailboxListener).event(event);
+        asynchronousEventDelivery.deliver(mailboxListener, event);
+        verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
+    }
+
+    @Test
+    public void deliverShouldWorkWhenThePoolIsFull() {
+        MockMailboxSession session = new MockMailboxSession("test");
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(),
+            session.getUser().getCoreUser(), null, null) {};
+        int operationCount = 10;
+        for (int i = 0; i < operationCount; i++) {
+            asynchronousEventDelivery.deliver(mailboxListener, event);
+        }
+        verify(mailboxListener, timeout(ONE_MINUTE).times(operationCount)).event(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/MixedEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/MixedEventDeliveryTest.java b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/MixedEventDeliveryTest.java
new file mode 100644
index 0000000..b697019
--- /dev/null
+++ b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/MixedEventDeliveryTest.java
@@ -0,0 +1,86 @@
+/****************************************************************
+ * 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.delivery;
+
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.metrics.api.NoopMetricFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class MixedEventDeliveryTest {
+
+    private static final int DELIVERY_DELAY = (int) TimeUnit.MILLISECONDS.toMillis(100);
+    private static final long ONE_MINUTE = 60000;
+    private MixedEventDelivery mixedEventDelivery;
+    private MailboxListener listener;
+
+    @Before
+    public void setUp() {
+        listener = mock(MailboxListener.class);
+        SynchronousEventDelivery synchronousEventDelivery = new SynchronousEventDelivery(new NoopMetricFactory());
+        AsynchronousEventDelivery asynchronousEventDelivery = new AsynchronousEventDelivery(2, synchronousEventDelivery);
+        mixedEventDelivery = new MixedEventDelivery(asynchronousEventDelivery, synchronousEventDelivery);
+    }
+
+    @After
+    public void tearDown() {
+        mixedEventDelivery.stop();
+    }
+
+    @Test
+    public void deliverShouldWorkOnSynchronousListeners() {
+        when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
+        mixedEventDelivery.deliver(listener, event);
+        verify(listener).event(event);
+    }
+
+    @Test
+    public void deliverShouldEventuallyDeliverOnAsynchronousListeners() {
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
+        when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
+        mixedEventDelivery.deliver(listener, event);
+        verify(listener, timeout(DELIVERY_DELAY * 10)).event(event);
+    }
+
+    @Test(timeout = ONE_MINUTE)
+    public void deliverShouldNotBlockOnAsynchronousListeners() {
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
+        when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
+        final CountDownLatch latch = new CountDownLatch(1);
+        doAnswer(invocation -> {
+            latch.await();
+            return null;
+        }).when(listener).event(event);
+        mixedEventDelivery.deliver(listener, event);
+        latch.countDown();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/SynchronousEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/SynchronousEventDeliveryTest.java b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/SynchronousEventDeliveryTest.java
new file mode 100644
index 0000000..95c4dfc
--- /dev/null
+++ b/mailbox/event/event-memory/src/test/java/org/apache/james/mailbox/events/delivery/SynchronousEventDeliveryTest.java
@@ -0,0 +1,60 @@
+/****************************************************************
+ * 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.delivery;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.metrics.api.NoopMetricFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SynchronousEventDeliveryTest {
+
+    private MailboxListener mailboxListener;
+    private SynchronousEventDelivery synchronousEventDelivery;
+
+    @Before
+    public void setUp() {
+        mailboxListener = mock(MailboxListener.class);
+        synchronousEventDelivery = new SynchronousEventDelivery(new NoopMetricFactory());
+    }
+
+    @Test
+    public void deliverShouldWork() {
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
+        synchronousEventDelivery.deliver(mailboxListener, event);
+        verify(mailboxListener).event(event);
+    }
+
+    @Test
+    public void deliverShouldNotPropagateException() {
+        MockMailboxSession session = new MockMailboxSession("test");
+        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(),
+            session.getUser().getCoreUser(),null, null) {};
+        doThrow(new RuntimeException()).when(mailboxListener).event(event);
+        synchronousEventDelivery.deliver(mailboxListener, event);
+        verify(mailboxListener).event(event);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/pom.xml b/mailbox/pom.xml
index 60cbe44..4361e93 100644
--- a/mailbox/pom.xml
+++ b/mailbox/pom.xml
@@ -62,6 +62,7 @@
         <module>tools/indexer</module>
         <module>tools/jpa-migrator</module>
         <module>tools/maildir-utils</module>
+        <module>event/event-memory</module>
     </modules>
 
     <issueManagement>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml
----------------------------------------------------------------------
diff --git a/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml b/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml
index 2bdc06e..03f3be7 100644
--- a/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml
+++ b/mailbox/spring/src/main/resources/META-INF/spring/event-system.xml
@@ -28,18 +28,18 @@
         <constructor-arg index="1" ref="event-registry"/>
     </bean>
 
-    <bean id="synchronous-event-delivery" class="org.apache.james.mailbox.store.event.SynchronousEventDelivery" lazy-init="true">
+    <bean id="synchronous-event-delivery" class="org.apache.james.mailbox.events.delivery.SynchronousEventDelivery" lazy-init="true">
         <constructor-arg index="0" ref="metricFactory"/>
     </bean>
 
     <bean id="event-registry" class="org.apache.james.mailbox.store.event.MailboxListenerRegistry"/>
 
-    <bean id="asynchronous-event-delivery" class="org.apache.james.mailbox.store.event.AsynchronousEventDelivery" lazy-init="true">
+    <bean id="asynchronous-event-delivery" class="org.apache.james.mailbox.events.delivery.AsynchronousEventDelivery" lazy-init="true">
         <constructor-arg index="0" ref="${event.delivery.thread.count}"/>
         <constructor-arg index="1" ref="synchronous-event-delivery"/>
     </bean>
 
-    <bean id="mixed-event-delivery" class="org.apache.james.mailbox.store.event.MixedEventDelivery" lazy-init="true">
+    <bean id="mixed-event-delivery" class="org.apache.james.mailbox.events.delivery.MixedEventDelivery" lazy-init="true">
         <constructor-arg index="0" ref="asynchronous-event-delivery"/>
         <constructor-arg index="1" ref="synchronous-event-delivery"/>
     </bean>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/store/pom.xml b/mailbox/store/pom.xml
index 0bc7684..3e3a4c5 100644
--- a/mailbox/store/pom.xml
+++ b/mailbox/store/pom.xml
@@ -43,6 +43,10 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-event-memory</artifactId>
+        </dependency>
+        <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-mime4j-core</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/AsynchronousEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/AsynchronousEventDelivery.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/AsynchronousEventDelivery.java
deleted file mode 100644
index 593de54..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/AsynchronousEventDelivery.java
+++ /dev/null
@@ -1,52 +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.store.event;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
-
-import javax.annotation.PreDestroy;
-
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.util.concurrent.NamedThreadFactory;
-
-public class AsynchronousEventDelivery implements EventDelivery {
-
-    private final ExecutorService threadPoolExecutor;
-    private final SynchronousEventDelivery synchronousEventDelivery;
-
-    public AsynchronousEventDelivery(int threadPoolSize, SynchronousEventDelivery synchronousEventDelivery) {
-        ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
-        this.threadPoolExecutor = Executors.newFixedThreadPool(threadPoolSize, threadFactory);
-        this.synchronousEventDelivery = synchronousEventDelivery;
-    }
-
-    @Override
-    public void deliver(MailboxListener mailboxListener, Event event) {
-        threadPoolExecutor.submit(() -> synchronousEventDelivery.deliver(mailboxListener, event));
-    }
-
-    @PreDestroy
-    public void stop() {
-        threadPoolExecutor.shutdownNow();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventDelivery.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventDelivery.java
deleted file mode 100644
index 517d296..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventDelivery.java
+++ /dev/null
@@ -1,29 +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.store.event;
-
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
-
-public interface EventDelivery {
-
-    void deliver(MailboxListener mailboxListener, Event event);
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MixedEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MixedEventDelivery.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MixedEventDelivery.java
deleted file mode 100644
index 1aab004..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MixedEventDelivery.java
+++ /dev/null
@@ -1,52 +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.store.event;
-
-import javax.annotation.PreDestroy;
-
-import org.apache.james.mailbox.Event;
-import org.apache.james.mailbox.MailboxListener;
-
-public class MixedEventDelivery implements EventDelivery {
-
-    private final AsynchronousEventDelivery asynchronousEventDelivery;
-    private final SynchronousEventDelivery synchronousEventDelivery;
-
-    public MixedEventDelivery(AsynchronousEventDelivery asynchronousEventDelivery,
-                              SynchronousEventDelivery synchronousEventDelivery) {
-        this.asynchronousEventDelivery = asynchronousEventDelivery;
-        this.synchronousEventDelivery = synchronousEventDelivery;
-    }
-
-    @Override
-    public void deliver(MailboxListener mailboxListener, Event event) {
-        if (mailboxListener.getExecutionMode().equals(MailboxListener.ExecutionMode.SYNCHRONOUS)) {
-            synchronousEventDelivery.deliver(mailboxListener, event);
-        } else {
-            asynchronousEventDelivery.deliver(mailboxListener, event);
-        }
-    }
-
-    @PreDestroy
-    public void stop() {
-        asynchronousEventDelivery.stop();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SynchronousEventDelivery.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SynchronousEventDelivery.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SynchronousEventDelivery.java
deleted file mode 100644
index df52819..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/SynchronousEventDelivery.java
+++ /dev/null
@@ -1,55 +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.store.event;
-
-import javax.inject.Inject;
-
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SynchronousEventDelivery implements EventDelivery {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(SynchronousEventDelivery.class);
-
-    private final MetricFactory metricFactory;
-
-    @Inject
-    public SynchronousEventDelivery(MetricFactory metricFactory) {
-        this.metricFactory = metricFactory;
-    }
-
-    @Override
-    public void deliver(MailboxListener mailboxListener, Event event) {
-        TimeMetric timer = metricFactory.timer("mailbox-listener-" + mailboxListener.getClass().getSimpleName());
-        try {
-            mailboxListener.event(event);
-        } catch (Throwable throwable) {
-            LOGGER.error("Error while processing listener {} for {}",
-                    mailboxListener.getClass().getCanonicalName(), event.getClass().getCanonicalName(),
-                    throwable);
-        } finally {
-            timer.stopAndPublish();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java
deleted file mode 100644
index 7331968..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.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.store.event;
-
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verify;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.metrics.api.NoopMetricFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class AsynchronousEventDeliveryTest {
-
-    private static final int ONE_MINUTE = (int) TimeUnit.MINUTES.toMillis(1);
-    private MailboxListener mailboxListener;
-    private AsynchronousEventDelivery asynchronousEventDelivery;
-
-    @Before
-    public void setUp() {
-        mailboxListener = mock(MailboxListener.class);
-        asynchronousEventDelivery = new AsynchronousEventDelivery(2,
-            new SynchronousEventDelivery(new NoopMetricFactory()));
-    }
-
-    @After
-    public void tearDown() {
-        asynchronousEventDelivery.stop();
-    }
-
-    @Test
-    public void deliverShouldWork() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
-        asynchronousEventDelivery.deliver(mailboxListener, event);
-        verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
-    }
-
-    @Test
-    public void deliverShouldNotPropagateException() {
-        MockMailboxSession session = new MockMailboxSession("test");
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(),
-            session.getUser().getCoreUser(), null, null) {};
-        doThrow(new RuntimeException()).when(mailboxListener).event(event);
-        asynchronousEventDelivery.deliver(mailboxListener, event);
-        verify(mailboxListener, timeout(ONE_MINUTE)).event(event);
-    }
-
-    @Test
-    public void deliverShouldWorkWhenThePoolIsFull() {
-        MockMailboxSession session = new MockMailboxSession("test");
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(),
-            session.getUser().getCoreUser(), null, null) {};
-        int operationCount = 10;
-        for (int i = 0; i < operationCount; i++) {
-            asynchronousEventDelivery.deliver(mailboxListener, event);
-        }
-        verify(mailboxListener, timeout(ONE_MINUTE).times(operationCount)).event(event);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
deleted file mode 100644
index 3c44dda..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java
+++ /dev/null
@@ -1,87 +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.store.event;
-
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.metrics.api.NoopMetricFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-
-public class MixedEventDeliveryTest {
-
-    private static final int DELIVERY_DELAY = (int) TimeUnit.MILLISECONDS.toMillis(100);
-    private static final long ONE_MINUTE = 60000;
-    private MixedEventDelivery mixedEventDelivery;
-    private MailboxListener listener;
-
-    @Before
-    public void setUp() {
-        listener = mock(MailboxListener.class);
-        SynchronousEventDelivery synchronousEventDelivery = new SynchronousEventDelivery(new NoopMetricFactory());
-        AsynchronousEventDelivery asynchronousEventDelivery = new AsynchronousEventDelivery(2, synchronousEventDelivery);
-        mixedEventDelivery = new MixedEventDelivery(asynchronousEventDelivery, synchronousEventDelivery);
-    }
-
-    @After
-    public void tearDown() {
-        mixedEventDelivery.stop();
-    }
-
-    @Test
-    public void deliverShouldWorkOnSynchronousListeners() {
-        when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS);
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
-        mixedEventDelivery.deliver(listener, event);
-        verify(listener).event(event);
-    }
-
-    @Test
-    public void deliverShouldEventuallyDeliverOnAsynchronousListeners() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
-        when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
-        mixedEventDelivery.deliver(listener, event);
-        verify(listener, timeout(DELIVERY_DELAY * 10)).event(event);
-    }
-
-    @Test(timeout = ONE_MINUTE)
-    public void deliverShouldNotBlockOnAsynchronousListeners() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
-        when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS);
-        final CountDownLatch latch = new CountDownLatch(1);
-        doAnswer(invocation -> {
-            latch.await();
-            return null;
-        }).when(listener).event(event);
-        mixedEventDelivery.deliver(listener, event);
-        latch.countDown();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
deleted file mode 100644
index cbe0c0a..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java
+++ /dev/null
@@ -1,60 +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.store.event;
-
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.mock.MockMailboxSession;
-import org.apache.james.metrics.api.NoopMetricFactory;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SynchronousEventDeliveryTest {
-
-    private MailboxListener mailboxListener;
-    private SynchronousEventDelivery synchronousEventDelivery;
-
-    @Before
-    public void setUp() {
-        mailboxListener = mock(MailboxListener.class);
-        synchronousEventDelivery = new SynchronousEventDelivery(new NoopMetricFactory());
-    }
-
-    @Test
-    public void deliverShouldWork() {
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {};
-        synchronousEventDelivery.deliver(mailboxListener, event);
-        verify(mailboxListener).event(event);
-    }
-
-    @Test
-    public void deliverShouldNotPropagateException() {
-        MockMailboxSession session = new MockMailboxSession("test");
-        MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(),
-            session.getUser().getCoreUser(),null, null) {};
-        doThrow(new RuntimeException()).when(mailboxListener).event(event);
-        synchronousEventDelivery.deliver(mailboxListener, event);
-        verify(mailboxListener).event(event);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3395277..6ce19bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -762,6 +762,11 @@
             </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
+                <artifactId>apache-james-mailbox-event-memory</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
                 <artifactId>apache-james-mailbox-jpa</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e0f830ce/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 835eccc..a139079 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
@@ -27,14 +27,14 @@ 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.store.event.AsynchronousEventDelivery;
+import org.apache.james.mailbox.events.delivery.AsynchronousEventDelivery;
+import org.apache.james.mailbox.events.delivery.EventDelivery;
+import org.apache.james.mailbox.events.delivery.MixedEventDelivery;
+import org.apache.james.mailbox.events.delivery.SynchronousEventDelivery;
 import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener;
 import org.apache.james.mailbox.store.event.DelegatingMailboxListener;
-import org.apache.james.mailbox.store.event.EventDelivery;
 import org.apache.james.mailbox.store.event.MailboxAnnotationListener;
 import org.apache.james.mailbox.store.event.MailboxListenerRegistry;
-import org.apache.james.mailbox.store.event.MixedEventDelivery;
-import org.apache.james.mailbox.store.event.SynchronousEventDelivery;
 import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.server.core.configuration.ConfigurationProvider;


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