You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/01/07 07:24:28 UTC
[james-project] 05/10: JAMES-3687 Provide a guice module to use pulsar mailqueue
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 93e4f74e782f832e8f9e7723d3997bb6f53c2a18
Author: Matthieu Baechler <ma...@apache.org>
AuthorDate: Wed Oct 13 22:55:18 2021 +0200
JAMES-3687 Provide a guice module to use pulsar mailqueue
Co-Authored-By: Jean Helou <jh...@codamens.fr>
---
server/container/guice/pom.xml | 6 ++
server/container/guice/queue/pulsar/pom.xml | 58 +++++++++++++
.../queue/pulsar/module/PulsarQueueModule.java | 96 ++++++++++++++++++++++
3 files changed, 160 insertions(+)
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
index 1363be1..ffed39d 100644
--- a/server/container/guice/pom.xml
+++ b/server/container/guice/pom.xml
@@ -73,6 +73,7 @@
<module>protocols/webadmin-rabbitmq-mailqueue</module>
<module>queue/activemq</module>
<module>queue/memory</module>
+ <module>queue/pulsar</module>
<module>queue/rabbitmq</module>
<module>sieve-file</module>
<module>sieve-jpa</module>
@@ -272,6 +273,11 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>queue-pulsar-guice</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>queue-rabbitmq-guice</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/server/container/guice/queue/pulsar/pom.xml b/server/container/guice/queue/pulsar/pom.xml
new file mode 100644
index 0000000..ca82b69
--- /dev/null
+++ b/server/container/guice/queue/pulsar/pom.xml
@@ -0,0 +1,58 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.james</groupId>
+ <artifactId>james-server-guice</artifactId>
+ <version>3.7.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>queue-pulsar-guice</artifactId>
+
+ <name>Apache James :: Server :: Guice :: Pulsar Mailqueue</name>
+ <description>Guice Module for Pulsar backed mailqueue</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-backends-pulsar</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-guice-configuration</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-queue-pulsar</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>testing-base</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/server/container/guice/queue/pulsar/src/main/java/org/apache/james/queue/pulsar/module/PulsarQueueModule.java b/server/container/guice/queue/pulsar/src/main/java/org/apache/james/queue/pulsar/module/PulsarQueueModule.java
new file mode 100644
index 0000000..953f212
--- /dev/null
+++ b/server/container/guice/queue/pulsar/src/main/java/org/apache/james/queue/pulsar/module/PulsarQueueModule.java
@@ -0,0 +1,96 @@
+/****************************************************************
+ * 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.queue.pulsar.module;
+
+import java.io.FileNotFoundException;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.apache.james.backends.pulsar.PulsarConfiguration;
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.Store;
+import org.apache.james.blob.mail.MimeMessagePartsId;
+import org.apache.james.blob.mail.MimeMessageStore;
+import org.apache.james.metrics.api.GaugeRegistry;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.james.queue.api.ManageableMailQueue;
+import org.apache.james.queue.pulsar.PulsarMailQueueFactory;
+import org.apache.james.utils.PropertiesProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provider;
+import com.google.inject.Provides;
+
+public class PulsarQueueModule extends AbstractModule {
+ static final String PULSAR_CONFIGURATION_NAME = "pulsar";
+ private static final Logger LOGGER = LoggerFactory.getLogger(PulsarQueueModule.class);
+
+ @Provides
+ @Named(PULSAR_CONFIGURATION_NAME)
+ @Singleton
+ private Configuration rawConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException {
+ try {
+ return propertiesProvider.getConfiguration(PULSAR_CONFIGURATION_NAME);
+ } catch (FileNotFoundException e) {
+ LOGGER.error("Could not find " + PULSAR_CONFIGURATION_NAME + " configuration file.");
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Provides
+ @Singleton
+ private PulsarConfiguration pulsarConfiguration(@Named(PULSAR_CONFIGURATION_NAME) Configuration configuration) {
+ return PulsarConfiguration.from(configuration);
+ }
+
+ @Provides
+ @Singleton
+ public MailQueueFactory<? extends ManageableMailQueue> mailQueue(PulsarConfiguration pulsarConfig,
+ BlobId.Factory blobIdFactory,
+ MimeMessageStore.Factory mimeFactory,
+ MailQueueItemDecoratorFactory decoratorFactory,
+ MetricFactory metricFactory,
+ GaugeRegistry gaugeRegistry) {
+ Store<MimeMessage, MimeMessagePartsId> mimeMessageMimeMessagePartsIdStore = mimeFactory.mimeMessageStore();
+ return new PulsarMailQueueFactory(
+ pulsarConfig,
+ blobIdFactory,
+ mimeMessageMimeMessagePartsIdStore,
+ decoratorFactory,
+ metricFactory,
+ gaugeRegistry
+ );
+ }
+
+ @Provides
+ @Singleton
+ public MailQueueFactory<?> mailQueue(Provider<MailQueueFactory<? extends ManageableMailQueue>> provider) {
+ return provider.get();
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org