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 2026/10/02 19:58:15 UTC
(james-project) branch master updated: [UPGRADE] Apache James ActiveMQ to Artemis (#3194)
This is an automated email from the ASF dual-hosted git repository.
chibenwa pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new b3951b6fc5 [UPGRADE] Apache James ActiveMQ to Artemis (#3194)
b3951b6fc5 is described below
commit b3951b6fc55a0630abf2bed0a55fbb1fd894d3b2
Author: ilya terskov <96...@users.noreply.github.com>
AuthorDate: Sat Oct 3 02:58:09 2026 +0700
[UPGRADE] Apache James ActiveMQ to Artemis (#3194)
- Replace embedded ActiveMQ Classic with ActiveMQ Artemis (in-VM)
- Remove ActiveMQ Classic proprietary BlobMessage implementation in favor of Artemis large messages
- Update metrics and health checks for Artemis
- Escape JMS property names to comply with Artemis identifier rules
- Add system property james.mail.queue.jmx.activated (default false) to control JMX
- Configure safe durability defaults in sample configuration
- Document migration in ADR 0076 and upgrade instructions
---
pom.xml | 55 ++--
.../sample-configuration/activemq.properties | 32 ++
.../src/main/resources/activemq.properties | 32 ++
.../queue/activemq/ActiveMQQueueModule.java | 27 +-
server/container/spring/pom.xml | 13 +-
.../apache/james/mailets/TemporaryJamesServer.java | 3 -
server/queue/queue-activemq/pom.xml | 24 +-
.../queue/activemq/ActiveMQCacheableMailQueue.java | 342 ---------------------
.../queue/activemq/ActiveMQConfiguration.java | 95 +++++-
.../queue/activemq/ActiveMQMailQueueFactory.java | 122 ++++----
.../queue/activemq/ActiveMQMailQueueItem.java | 70 -----
.../james/queue/activemq/ActiveMQSupport.java | 44 ---
.../james/queue/activemq/EmbeddedActiveMQ.java | 132 ++++----
.../queue/activemq/FileSystemBlobStrategy.java | 135 --------
.../activemq/FileSystemBlobTransferPolicy.java | 75 -----
.../activemq/MimeMessageBlobMessageSource.java | 72 -----
.../metric/ActiveMQMetricCollectorImpl.java | 202 ------------
.../META-INF/spring/activemq-queue-context.xml | 92 +++---
.../queue/activemq/ActiveMQHealthCheckTest.java | 17 +-
.../queue/activemq/ActiveMQMailQueueBlobTest.java | 213 -------------
.../activemq/ActiveMQMailQueueFactoryTest.java | 33 +-
.../queue/activemq/ActiveMQMailQueueTest.java | 23 +-
.../metric/ActiveMQMetricCollectorTest.java | 144 ---------
server/queue/queue-jms/pom.xml | 10 +-
.../james/queue/jms/JMSCacheableMailQueue.java | 83 ++++-
.../apache/james/queue/jms/BrokerExtension.java | 69 +++--
.../jms/JMSCacheableMailQueueFactoryTest.java | 8 +-
.../jms/JMSCacheableMailQueuePropertyNameTest.java | 200 ++++++++++++
.../james/queue/jms/JMSCacheableMailQueueTest.java | 17 +-
src/adr/0076-artemis-mailqueue-migration.md | 67 ++++
upgrade-instructions.md | 17 +
31 files changed, 821 insertions(+), 1647 deletions(-)
diff --git a/pom.xml b/pom.xml
index 26a8765998..975f65cc54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -622,9 +622,9 @@
<james.groupId>org.apache.james</james.groupId>
<james.protocols.groupId>${james.groupId}.protocols</james.protocols.groupId>
- <activemq.version>6.2.7</activemq.version>
<apache-mime4j.version>0.8.15</apache-mime4j.version>
- <apache.openjpa.version>4.1.1</apache.openjpa.version><!-- Align with EE10 Persistence 3.1 & Transactions 2.0: https://openjpa.apache.org/ -->
+ <apache.openjpa.version>4.1.1</apache.openjpa.version>
+ <!-- Align with EE10 Persistence 3.1 & Transactions 2.0: https://openjpa.apache.org/ -->
<h2.version>2.3.232</h2.version>
<log4j2.version>2.25.5</log4j2.version>
@@ -694,6 +694,7 @@
<jacoco-maven-plugin.version>0.8.13</jacoco-maven-plugin.version>
<javacrumbs.json-unit.version>4.1.1</javacrumbs.json-unit.version>
<fastutil-core.version>8.5.15</fastutil-core.version>
+ <git.useNativeGit>true</git.useNativeGit>
</properties>
<dependencyManagement>
@@ -2548,6 +2549,13 @@
<artifactId>micrometer-tracing</artifactId>
<version>${io.micrometer.tracing.version}</version>
</dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-bom</artifactId>
+ <version>${netty.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
@@ -2677,20 +2685,12 @@
<version>4.0.2</version>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-broker</artifactId>
- <version>${activemq.version}</version>
- <exclusions>
- <!-- exclude this, it's only used in the authentication plugin which we don't use -->
- <!-- exclude this, we don't use osgi yet -->
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.10.15</version>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
+ <groupId>org.apache.artemis</groupId>
<artifactId>artemis-jakarta-client</artifactId>
<version>${activmq-artemis.version}</version>
<exclusions>
@@ -2700,10 +2700,11 @@
</exclusion>
</exclusions>
</dependency>
+ <!-- Artemis embedded server (replaces legacy ActiveMQ BrokerService) -->
<dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.10.15</version>
+ <groupId>org.apache.artemis</groupId>
+ <artifactId>artemis-jakarta-server</artifactId>
+ <version>${activmq-artemis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -4219,8 +4220,7 @@
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<injectAllReactorProjects>true</injectAllReactorProjects>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
- <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
- </generateGitPropertiesFilename>
+ <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<format>json</format>
<gitDescribe>
@@ -4236,7 +4236,7 @@
</includeOnlyProperties>
<prefix>git</prefix>
<skip>false</skip>
- <useNativeGit>true</useNativeGit>
+ <useNativeGit>${git.useNativeGit}</useNativeGit>
<verbose>false</verbose>
</configuration>
<executions>
@@ -4356,7 +4356,7 @@
</inputExcludes>
</configuration>
</plugin>
-<!--
+ <!--
Even using the -no-fork variant of hte tasks, generating this reports
triggers unresolved symbols errors which need to be further investigated
trakced in https://issues.apache.org/jira/browse/JAMES-4178
@@ -4374,7 +4374,7 @@
</plugin>
-->
-<!--
+ <!--
This plugin is not compatible with jdk21, so I disabled it
temporarily.
it appears the successor is spotbugs but we should do this migration
@@ -4603,5 +4603,16 @@
</pluginManagement>
</build>
</profile>
+ <profile>
+ <id>windows-git</id>
+ <activation>
+ <os>
+ <family>windows</family>
+ </os>
+ </activation>
+ <properties>
+ <git.useNativeGit>false</git.useNativeGit>
+ </properties>
+ </profile>
</profiles>
</project>
diff --git a/server/apps/postgres-app/sample-configuration/activemq.properties b/server/apps/postgres-app/sample-configuration/activemq.properties
new file mode 100644
index 0000000000..e1b1adedcc
--- /dev/null
+++ b/server/apps/postgres-app/sample-configuration/activemq.properties
@@ -0,0 +1,32 @@
+# ==============================================================================
+# Apache ActiveMQ Artemis Embedded Queue Configuration
+# ==============================================================================
+# Controls persistence, journal I/O batching, and client interaction for the
+# embedded Artemis broker backing James mail queues (spool, outgoing, etc.).
+# ==============================================================================
+
+# Transactional journal sync (true = full ACID durability / Zero Data Loss)
+# Messages are guaranteed to be flushed to persistent storage upon commit.
+artemis.journal.sync.transactional=true
+
+# Non-transactional journal sync (avoid redundant fsync for non-critical metadata)
+artemis.journal.sync.non.transactional=true
+
+# High-precision journal group commit timeout in nanoseconds (NIO).
+# 1,500,000 ns = 1.5 ms. Coalesces concurrent writes across parallel threads
+# into a single physical disk flush, drastically reducing disk latency spikes.
+artemis.journal.buffer.timeout.nio=1500000
+
+# Write buffer size for journal NIO operations (default: 1 MB)
+artemis.journal.buffer.size.nio=1048576
+
+# Maximum concurrent direct/NIO write operations allowed
+artemis.journal.max.io.nio=500
+
+# Enables asynchronous non-blocking connection execution inside Artemis engine
+artemis.async.connection.execution=true
+
+# JMS Client Connection Factory optimization
+# Delegates persistence waiting directly to the optimized journal engine
+artemis.client.block.on.durable.send=true
+artemis.client.block.on.acknowledge=false
diff --git a/server/apps/spring-app/src/main/resources/activemq.properties b/server/apps/spring-app/src/main/resources/activemq.properties
new file mode 100644
index 0000000000..e1b1adedcc
--- /dev/null
+++ b/server/apps/spring-app/src/main/resources/activemq.properties
@@ -0,0 +1,32 @@
+# ==============================================================================
+# Apache ActiveMQ Artemis Embedded Queue Configuration
+# ==============================================================================
+# Controls persistence, journal I/O batching, and client interaction for the
+# embedded Artemis broker backing James mail queues (spool, outgoing, etc.).
+# ==============================================================================
+
+# Transactional journal sync (true = full ACID durability / Zero Data Loss)
+# Messages are guaranteed to be flushed to persistent storage upon commit.
+artemis.journal.sync.transactional=true
+
+# Non-transactional journal sync (avoid redundant fsync for non-critical metadata)
+artemis.journal.sync.non.transactional=true
+
+# High-precision journal group commit timeout in nanoseconds (NIO).
+# 1,500,000 ns = 1.5 ms. Coalesces concurrent writes across parallel threads
+# into a single physical disk flush, drastically reducing disk latency spikes.
+artemis.journal.buffer.timeout.nio=1500000
+
+# Write buffer size for journal NIO operations (default: 1 MB)
+artemis.journal.buffer.size.nio=1048576
+
+# Maximum concurrent direct/NIO write operations allowed
+artemis.journal.max.io.nio=500
+
+# Enables asynchronous non-blocking connection execution inside Artemis engine
+artemis.async.connection.execution=true
+
+# JMS Client Connection Factory optimization
+# Delegates persistence waiting directly to the optimized journal engine
+artemis.client.block.on.durable.send=true
+artemis.client.block.on.acknowledge=false
diff --git a/server/container/guice/queue/activemq/src/main/java/org/apache/james/modules/queue/activemq/ActiveMQQueueModule.java b/server/container/guice/queue/activemq/src/main/java/org/apache/james/modules/queue/activemq/ActiveMQQueueModule.java
index c78b55e154..36bcef628c 100644
--- a/server/container/guice/queue/activemq/src/main/java/org/apache/james/modules/queue/activemq/ActiveMQQueueModule.java
+++ b/server/container/guice/queue/activemq/src/main/java/org/apache/james/modules/queue/activemq/ActiveMQQueueModule.java
@@ -23,8 +23,6 @@ import java.io.FileNotFoundException;
import jakarta.jms.ConnectionFactory;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.james.core.healthcheck.HealthCheck;
@@ -33,7 +31,7 @@ import org.apache.james.queue.activemq.ActiveMQHealthCheck;
import org.apache.james.queue.activemq.ActiveMQMailQueueFactory;
import org.apache.james.queue.activemq.EmbeddedActiveMQ;
import org.apache.james.queue.activemq.metric.ActiveMQMetricCollector;
-import org.apache.james.queue.activemq.metric.ActiveMQMetricCollectorImpl;
+import org.apache.james.queue.activemq.metric.ActiveMQMetricCollectorNoop;
import org.apache.james.queue.api.MailQueue;
import org.apache.james.queue.api.MailQueueFactory;
import org.apache.james.queue.api.ManageableMailQueue;
@@ -50,6 +48,10 @@ import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.multibindings.ProvidesIntoSet;
+/**
+ * Guice module for the Artemis-backed mail queue.
+ * Replaces the legacy ActiveMQ embedded broker with Apache ActiveMQ Artemis.
+ */
public class ActiveMQQueueModule extends AbstractModule {
private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQQueueModule.class);
@@ -57,26 +59,31 @@ public class ActiveMQQueueModule extends AbstractModule {
@Override
protected void configure() {
- bind(PersistenceAdapter.class).to(KahaDBPersistenceAdapter.class);
- bind(KahaDBPersistenceAdapter.class).in(Scopes.SINGLETON);
bind(EmbeddedActiveMQ.class).in(Scopes.SINGLETON);
bind(ActiveMQMailQueueFactory.class).in(Scopes.SINGLETON);
- bind(ActiveMQMetricCollector.class).to(ActiveMQMetricCollectorImpl.class);
- bind(ActiveMQMetricCollectorImpl.class).in(Scopes.SINGLETON);
+ // ActiveMQMetricCollector polled ActiveMQ Classic's proprietary Statistics Plugin advisory queues.
+ // Artemis does not use this plugin; James queue metrics (enqueued, dequeued, queueSize) continue
+ // to be gathered directly by JMSCacheableMailQueue via MetricFactory & GaugeRegistry.
+ // Broker-level Artemis metrics are exposed via native Artemis JMX / Micrometer plugins.
+ bind(ActiveMQMetricCollector.class).to(ActiveMQMetricCollectorNoop.class);
+ bind(ActiveMQMetricCollectorNoop.class).in(Scopes.SINGLETON);
Multibinder.newSetBinder(binder(), HealthCheck.class).addBinding().to(ActiveMQHealthCheck.class);
}
-
+
@Provides
@Singleton
- ConnectionFactory provideEmbededActiveMQ(EmbeddedActiveMQ embeddedActiveMQ) {
+ ConnectionFactory provideEmbeddedArtemis(EmbeddedActiveMQ embeddedActiveMQ) {
return embeddedActiveMQ.getConnectionFactory();
}
+ private static final String JMX_ACTIVATED_PROPERTY = "james.mail.queue.jmx.activated";
+
@Provides
@Singleton
public MailQueueFactory<? extends ManageableMailQueue> createActiveMQManageableMailQueueFactory(ActiveMQMailQueueFactory activeMQMailQueueFactory) {
- activeMQMailQueueFactory.setUseJMX(true);
+ boolean useJmx = Boolean.parseBoolean(System.getProperty(JMX_ACTIVATED_PROPERTY, "false"));
+ activeMQMailQueueFactory.setUseJMX(useJmx);
activeMQMailQueueFactory.init();
return activeMQMailQueueFactory;
}
diff --git a/server/container/spring/pom.xml b/server/container/spring/pom.xml
index 94e4270403..8cf736957e 100644
--- a/server/container/spring/pom.xml
+++ b/server/container/spring/pom.xml
@@ -128,15 +128,10 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-spring</artifactId>
- <version>${activemq.version}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
+ <!-- Artemis Jakarta Server replaces legacy activemq-spring for embedded broker -->
+ <groupId>org.apache.artemis</groupId>
+ <artifactId>artemis-jakarta-server</artifactId>
+ <version>${activmq-artemis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git a/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/TemporaryJamesServer.java b/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/TemporaryJamesServer.java
index 1f136009cd..a158d66783 100644
--- a/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/TemporaryJamesServer.java
+++ b/server/mailet/integration-testing/src/main/java/org/apache/james/mailets/TemporaryJamesServer.java
@@ -31,8 +31,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import org.apache.activemq.store.PersistenceAdapter;
-import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.commons.io.IOUtils;
import org.apache.james.GuiceJamesServer;
@@ -154,7 +152,6 @@ public class TemporaryJamesServer {
jamesServer = GuiceJamesServer.forConfiguration(configuration)
.combineWith(serverBaseModule)
.combineWith(new MemoryUsersRepositoryModule())
- .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
.overrideWith(additionalModules)
.overrideWith(new TestJMAPServerModule())
.overrideWith((binder) -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION));
diff --git a/server/queue/queue-activemq/pom.xml b/server/queue/queue-activemq/pom.xml
index 912cfe4353..a09b1a3b37 100644
--- a/server/queue/queue-activemq/pom.xml
+++ b/server/queue/queue-activemq/pom.xml
@@ -33,12 +33,6 @@
<name>Apache James :: Server :: Mail Queue :: ActiveMQ</name>
<dependencies>
- <dependency>
- <?SORTPOM IGNORE?>
- <groupId>io.netty</groupId>
- <artifactId>netty-transport</artifactId>
- <?SORTPOM RESUME?>
- </dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>apache-mailet-api</artifactId>
@@ -76,6 +70,10 @@
<artifactId>james-server-testing</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>metrics-api</artifactId>
+ </dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>metrics-tests</artifactId>
@@ -94,18 +92,14 @@
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
+ <!-- Artemis Jakarta Client (JMS transport) -->
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-broker</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-kahadb-store</artifactId>
- <version>${activemq.version}</version>
+ <groupId>org.apache.artemis</groupId>
+ <artifactId>artemis-jakarta-client</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jakarta-client</artifactId>
+ <groupId>org.apache.artemis</groupId>
+ <artifactId>artemis-jakarta-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.angus</groupId>
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQCacheableMailQueue.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQCacheableMailQueue.java
deleted file mode 100644
index e9d9048688..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQCacheableMailQueue.java
+++ /dev/null
@@ -1,342 +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.queue.activemq;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.List;
-import java.util.Map;
-
-import jakarta.jms.ConnectionFactory;
-import jakarta.jms.JMSException;
-import jakarta.jms.MapMessage;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.ObjectMessage;
-import jakarta.jms.Queue;
-import jakarta.jms.Session;
-import jakarta.jms.TemporaryQueue;
-import jakarta.mail.MessagingException;
-import jakarta.mail.internet.MimeMessage;
-
-import org.apache.activemq.ActiveMQSession;
-import org.apache.activemq.BlobMessage;
-import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.activemq.util.JMSExceptionSupport;
-import org.apache.james.metrics.api.GaugeRegistry;
-import org.apache.james.metrics.api.MetricFactory;
-import org.apache.james.queue.api.MailQueue;
-import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
-import org.apache.james.queue.api.MailQueueName;
-import org.apache.james.queue.jms.JMSCacheableMailQueue;
-import org.apache.james.server.core.MailImpl;
-import org.apache.james.server.core.MimeMessageInputStream;
-import org.apache.james.server.core.MimeMessageSource;
-import org.apache.james.server.core.MimeMessageWrapper;
-import org.apache.mailet.Attribute;
-import org.apache.mailet.AttributeValue;
-import org.apache.mailet.Mail;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import reactor.core.publisher.Mono;
-
-/**
- * <p>
- * {@link MailQueue} implementation which use an ActiveMQ Queue.
- * <p>
- * </p>
- * This implementation require at ActiveMQ 5.4.0+.
- * <p>
- * </p>
- * When a {@link Mail} attribute is found and is not one of the supported
- * primitives, then the toString() method is called on the attribute value to
- * convert it
- * <p>
- * </p>
- * The implementation use {@link BlobMessage} or {@link ObjectMessage},
- * depending on the constructor which was used
- * <p>
- * </p>
- * See <a
- * href="http://activemq.apache.org/blob-messages.html">http://activemq.apache
- * .org/blob-messages.html</a> for more details
- * <p>
- * </p>
- * Some other supported feature is handling of priorities. See:<br>
- * <a href="http://activemq.apache.org/how-can-i-support-priority-queues.html">
- * http://activemq.apache.org/how-can-i-support-priority-queues.html</a>
- * <p>
- * </p>
- * For this just add a {@link Mail} attribute with name {@link #MAIL_PRIORITY}
- * to it. It should use one of the following value {@link #LOW_PRIORITY},
- * {@link #NORMAL_PRIORITY}, {@link #HIGH_PRIORITY}
- * <p>
- * </p>
- * To have a good throughput you should use a caching connection factory. </p>
- */
-public class ActiveMQCacheableMailQueue extends JMSCacheableMailQueue implements ActiveMQSupport {
- private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQCacheableMailQueue.class);
-
- private final boolean useBlob;
-
- /**
- * Construct a {@link ActiveMQCacheableMailQueue} which only use {@link BlobMessage}
- *
- */
- public ActiveMQCacheableMailQueue(ConnectionFactory connectionFactory, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, MailQueueName queuename, MetricFactory metricFactory,
- GaugeRegistry gaugeRegistry) {
- this(connectionFactory, mailQueueItemDecoratorFactory, queuename, true, metricFactory, gaugeRegistry);
- }
-
- /**
- * Construct a new ActiveMQ based {@link MailQueue}.
- *
- * @param connectionFactory
- * @param queuename
- * @param useBlob
- */
- public ActiveMQCacheableMailQueue(ConnectionFactory connectionFactory, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, MailQueueName queuename, boolean useBlob, MetricFactory metricFactory,
- GaugeRegistry gaugeRegistry) {
- super(connectionFactory, mailQueueItemDecoratorFactory, queuename, metricFactory, gaugeRegistry);
- this.useBlob = useBlob;
- }
-
- @Override
- protected MailImpl.Builder populateMail(Message message) throws JMSException {
- MailImpl.Builder builder = super.populateMail(message);
- if (message instanceof BlobMessage) {
- BlobMessage blobMessage = (BlobMessage) message;
- try {
- // store URL and queueName for later usage
- builder.addAttribute(new Attribute(JAMES_BLOB_URL, AttributeValue.of(blobMessage.getURL())));
- builder.addAttribute(new Attribute(JAMES_QUEUE_NAME, AttributeValue.of(queueName.asString())));
- } catch (MalformedURLException e) {
- // Ignore on error
- LOGGER.debug("Unable to get url from blobmessage for mail");
- }
- }
- return builder;
- }
-
- @Override
- protected MimeMessage mimeMessage(Message message) throws MessagingException, JMSException {
- if (message instanceof BlobMessage) {
- try {
- BlobMessage blobMessage = (BlobMessage) message;
- MimeMessageSource source = new MimeMessageBlobMessageSource(blobMessage);
- return new MimeMessageWrapper(source);
-
- } catch (JMSException e) {
- throw new MailQueueException("Unable to populate MimeMessage for mail", e);
- }
- } else {
- return super.mimeMessage(message);
- }
- }
-
-
- /**
- * Produce the mail to the JMS Queue
- */
- @Override
- protected void produceMail(Map<String, Object> props, int msgPrio, Mail mail) throws JMSException, MessagingException, IOException {
- BlobMessage blobMessage = null;
- boolean reuse = false;
-
- try {
-
- // check if we should use a blob message here
- if (useBlob) {
- ActiveMQSession amqSession = getAMQSession(session);
-
- /*
- * Remove this optimization as it could lead to problems when the same blob content
- * is shared across different messages.
- *
- * I still think it would be a good idea to somehow do this but at the moment it's just
- * safer to disable it.
- *
- * TODO: Re-Enable it again once it works!
- *
- * See JAMES-1240
- if (wrapper instanceof MimeMessageCopyOnWriteProxy) {
- wrapper = ((MimeMessageCopyOnWriteProxy) mm).getWrappedMessage();
- }
-
- if (wrapper instanceof MimeMessageWrapper) {
- URL blobUrl = (URL) mail.getAttribute(JAMES_BLOB_URL);
- String fromQueue = (String) mail.getAttribute(JAMES_QUEUE_NAME);
- MimeMessageWrapper mwrapper = (MimeMessageWrapper) wrapper;
-
- if (blobUrl != null && fromQueue != null && mwrapper.isModified() == false) {
- // the message content was not changed so don't need to
- // upload it again and can just point to the url
- blobMessage = amqSession.createBlobMessage(blobUrl);
- reuse = true;
- }
-
- }*/
- if (blobMessage == null) {
- // just use the MimeMessageInputStream which can read every
- // MimeMessage implementation
- blobMessage = amqSession.createBlobMessage(new MimeMessageInputStream(mail.getMessage()));
- }
-
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- blobMessage.setObjectProperty(entry.getKey(), entry.getValue());
- }
- producer.send(blobMessage, Message.DEFAULT_DELIVERY_MODE, msgPrio, Message.DEFAULT_TIME_TO_LIVE);
-
- } else {
- super.produceMail(props, msgPrio, mail);
- }
- } catch (JMSException e) {
- if (!reuse && blobMessage instanceof ActiveMQBlobMessage) {
- ((ActiveMQBlobMessage) blobMessage).deleteFile();
- }
- throw e;
- }
- }
-
- /**
- * Cast the given {@link Session} to an {@link ActiveMQSession}
- *
- * @param session
- * @return amqSession
- * @throws JMSException
- */
- protected ActiveMQSession getAMQSession(Session session) {
- return (ActiveMQSession) session;
- }
-
- @Override
- protected Mono<MailQueueItem> createMailQueueItem(Session session, MessageConsumer consumer, Message message) throws JMSException, MessagingException {
- try {
- Mail mail = createMail(message);
- ActiveMQMailQueueItem activeMQMailQueueItem = new ActiveMQMailQueueItem(mail, session, consumer, message);
- return Mono.just(mailQueueItemDecoratorFactory.decorate(activeMQMailQueueItem, queueName));
- } catch (MessagingException e) {
- if (e.getCause() instanceof FileNotFoundException) {
- LOGGER.warn("Blob message cannot be found, discarding email", e);
- try {
- session.commit();
- } catch (JMSException ex) {
- throw new MailQueueException("Unable to commit dequeue operation for mail", ex);
- } finally {
- JMSCacheableMailQueue.closeConsumer(consumer);
- JMSCacheableMailQueue.closeSession(session);
- }
- return Mono.empty();
- }
- return Mono.error(e);
- }
- }
-
- @Override
- public List<Message> removeWithSelector(String selector) throws MailQueueException {
- List<Message> mList = super.removeWithSelector(selector);
-
- // Handle the blob messages
- for (Message m : mList) {
- if (m instanceof ActiveMQBlobMessage) {
- try {
- // Should get remove once this issue is closed:
- // https://issues.apache.org/activemq/browse/AMQ-3018
- ((ActiveMQBlobMessage) m).deleteFile();
- } catch (Exception e) {
- LOGGER.error("Unable to delete blob file for message {}", m, e);
- }
- }
- }
- return mList;
- }
-
- @Override
- protected Message copy(Session session, Message m) throws JMSException {
- if (m instanceof ActiveMQBlobMessage) {
- ActiveMQBlobMessage b = (ActiveMQBlobMessage) m;
- ActiveMQBlobMessage copy = (ActiveMQBlobMessage) getAMQSession(session).createBlobMessage(b.getURL());
- try {
- copy.setProperties(b.getProperties());
- } catch (IOException e) {
- throw JMSExceptionSupport.create("Unable to copy message " + m, e);
- }
- return copy;
- } else {
- return super.copy(session, m);
- }
- }
-
- /**
- * Try to use ActiveMQ StatisticsPlugin to get size and if that fails
- * fallback to {@link JMSCacheableMailQueue#getSize()}
- */
- @Override
- public long getSize() throws MailQueueException {
- MessageConsumer consumer = null;
- MessageProducer producer = null;
- TemporaryQueue replyTo = null;
-
- try {
- replyTo = session.createTemporaryQueue();
- consumer = session.createConsumer(replyTo);
-
- Queue myQueue = session.createQueue(queueName.asString());
- producer = session.createProducer(null);
-
- String queueName = "ActiveMQ.Statistics.Destination." + myQueue.getQueueName();
- Queue query = session.createQueue(queueName);
-
- Message msg = session.createMessage();
- msg.setJMSReplyTo(replyTo);
- producer.send(query, msg);
- MapMessage reply = (MapMessage) consumer.receive(2000);
- if (reply != null && reply.itemExists("size")) {
- try {
- return reply.getLong("size");
- } catch (NumberFormatException e) {
- return super.getSize();
- }
- }
- return super.getSize();
- } catch (Exception e) {
- throw new MailQueueException("Unable to remove mails", e);
-
- } finally {
- closeConsumer(consumer);
- closeProducer(producer);
- if (replyTo != null) {
- try {
-
- // we need to delete the temporary queue to be sure we will
- // free up memory if thats not done and a pool is used
- // its possible that we will register a new mbean in jmx for
- // every TemporaryQueue which will never get unregistered
- replyTo.delete();
- } catch (JMSException e) {
- LOGGER.error("Error while deleting temporary queue", e);
- }
- }
- }
- }
-
-}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQConfiguration.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQConfiguration.java
index b0b5d4b75f..c92761edaa 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQConfiguration.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQConfiguration.java
@@ -26,8 +26,42 @@ public class ActiveMQConfiguration {
private static final String ADJUST_USAGE_LIMITS = "adjust.usage.limits";
private static final boolean ADJUST_USAGE_LIMITS_DEFAULT = false;
+ // Artemis performance & async/batching parameters
+ private static final String JOURNAL_SYNC_TRANSACTIONAL = "artemis.journal.sync.transactional";
+ private static final boolean JOURNAL_SYNC_TRANSACTIONAL_DEFAULT = true;
+
+ private static final String JOURNAL_SYNC_NON_TRANSACTIONAL = "artemis.journal.sync.non.transactional";
+ private static final boolean JOURNAL_SYNC_NON_TRANSACTIONAL_DEFAULT = true;
+
+ private static final String JOURNAL_BUFFER_TIMEOUT_NIO = "artemis.journal.buffer.timeout.nio";
+ // Default 1_500_000 ns (1.5 ms) enables group commit across concurrent threads
+ private static final int JOURNAL_BUFFER_TIMEOUT_NIO_DEFAULT = 1_500_000;
+
+ private static final String JOURNAL_BUFFER_SIZE_NIO = "artemis.journal.buffer.size.nio";
+ private static final int JOURNAL_BUFFER_SIZE_NIO_DEFAULT = 1024 * 1024; // 1 MB write buffer
+
+ private static final String JOURNAL_MAX_IO_NIO = "artemis.journal.max.io.nio";
+ private static final int JOURNAL_MAX_IO_NIO_DEFAULT = 500;
+
+ private static final String ASYNC_CONNECTION_EXECUTION = "artemis.async.connection.execution";
+ private static final boolean ASYNC_CONNECTION_EXECUTION_DEFAULT = true;
+
+ private static final String CLIENT_BLOCK_ON_DURABLE_SEND = "artemis.client.block.on.durable.send";
+ private static final boolean CLIENT_BLOCK_ON_DURABLE_SEND_DEFAULT = true;
+
+ private static final String CLIENT_BLOCK_ON_ACKNOWLEDGE = "artemis.client.block.on.acknowledge";
+ private static final boolean CLIENT_BLOCK_ON_ACKNOWLEDGE_DEFAULT = true;
+
private final ActiveMQMetricConfiguration metricConfiguration;
private final boolean adjustUsageLimits;
+ private final boolean journalSyncTransactional;
+ private final boolean journalSyncNonTransactional;
+ private final int journalBufferTimeoutNIO;
+ private final int journalBufferSizeNIO;
+ private final int journalMaxIONIO;
+ private final boolean asyncConnectionExecution;
+ private final boolean clientBlockOnDurableSend;
+ private final boolean clientBlockOnAcknowledge;
public static ActiveMQConfiguration getDefault() {
return from(new BaseConfiguration());
@@ -36,12 +70,37 @@ public class ActiveMQConfiguration {
public static ActiveMQConfiguration from(Configuration configuration) {
return new ActiveMQConfiguration(
ActiveMQMetricConfiguration.from(configuration),
- configuration.getBoolean(ADJUST_USAGE_LIMITS, ADJUST_USAGE_LIMITS_DEFAULT));
+ configuration.getBoolean(ADJUST_USAGE_LIMITS, ADJUST_USAGE_LIMITS_DEFAULT),
+ configuration.getBoolean(JOURNAL_SYNC_TRANSACTIONAL, JOURNAL_SYNC_TRANSACTIONAL_DEFAULT),
+ configuration.getBoolean(JOURNAL_SYNC_NON_TRANSACTIONAL, JOURNAL_SYNC_NON_TRANSACTIONAL_DEFAULT),
+ configuration.getInt(JOURNAL_BUFFER_TIMEOUT_NIO, JOURNAL_BUFFER_TIMEOUT_NIO_DEFAULT),
+ configuration.getInt(JOURNAL_BUFFER_SIZE_NIO, JOURNAL_BUFFER_SIZE_NIO_DEFAULT),
+ configuration.getInt(JOURNAL_MAX_IO_NIO, JOURNAL_MAX_IO_NIO_DEFAULT),
+ configuration.getBoolean(ASYNC_CONNECTION_EXECUTION, ASYNC_CONNECTION_EXECUTION_DEFAULT),
+ configuration.getBoolean(CLIENT_BLOCK_ON_DURABLE_SEND, CLIENT_BLOCK_ON_DURABLE_SEND_DEFAULT),
+ configuration.getBoolean(CLIENT_BLOCK_ON_ACKNOWLEDGE, CLIENT_BLOCK_ON_ACKNOWLEDGE_DEFAULT));
}
- private ActiveMQConfiguration(ActiveMQMetricConfiguration metricConfiguration, boolean adjustUsageLimits) {
+ private ActiveMQConfiguration(ActiveMQMetricConfiguration metricConfiguration,
+ boolean adjustUsageLimits,
+ boolean journalSyncTransactional,
+ boolean journalSyncNonTransactional,
+ int journalBufferTimeoutNIO,
+ int journalBufferSizeNIO,
+ int journalMaxIONIO,
+ boolean asyncConnectionExecution,
+ boolean clientBlockOnDurableSend,
+ boolean clientBlockOnAcknowledge) {
this.metricConfiguration = metricConfiguration;
this.adjustUsageLimits = adjustUsageLimits;
+ this.journalSyncTransactional = journalSyncTransactional;
+ this.journalSyncNonTransactional = journalSyncNonTransactional;
+ this.journalBufferTimeoutNIO = journalBufferTimeoutNIO;
+ this.journalBufferSizeNIO = journalBufferSizeNIO;
+ this.journalMaxIONIO = journalMaxIONIO;
+ this.asyncConnectionExecution = asyncConnectionExecution;
+ this.clientBlockOnDurableSend = clientBlockOnDurableSend;
+ this.clientBlockOnAcknowledge = clientBlockOnAcknowledge;
}
public ActiveMQMetricConfiguration getMetricConfiguration() {
@@ -51,4 +110,36 @@ public class ActiveMQConfiguration {
public boolean isAdjustUsageLimits() {
return adjustUsageLimits;
}
+
+ public boolean isJournalSyncTransactional() {
+ return journalSyncTransactional;
+ }
+
+ public boolean isJournalSyncNonTransactional() {
+ return journalSyncNonTransactional;
+ }
+
+ public int getJournalBufferTimeoutNIO() {
+ return journalBufferTimeoutNIO;
+ }
+
+ public int getJournalBufferSizeNIO() {
+ return journalBufferSizeNIO;
+ }
+
+ public int getJournalMaxIONIO() {
+ return journalMaxIONIO;
+ }
+
+ public boolean isAsyncConnectionExecution() {
+ return asyncConnectionExecution;
+ }
+
+ public boolean isClientBlockOnDurableSend() {
+ return clientBlockOnDurableSend;
+ }
+
+ public boolean isClientBlockOnAcknowledge() {
+ return clientBlockOnAcknowledge;
+ }
}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactory.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactory.java
index 920b2d2e3b..b587445bad 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactory.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactory.java
@@ -1,64 +1,58 @@
-/****************************************************************
- * 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.activemq;
-
-import jakarta.inject.Inject;
-import jakarta.jms.ConnectionFactory;
-
-import org.apache.james.metrics.api.GaugeRegistry;
-import org.apache.james.metrics.api.MetricFactory;
-import org.apache.james.queue.activemq.metric.ActiveMQMetricCollector;
-import org.apache.james.queue.api.MailQueueFactory;
-import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
-import org.apache.james.queue.api.MailQueueName;
-import org.apache.james.queue.api.ManageableMailQueue;
-import org.apache.james.queue.jms.JMSMailQueueFactory;
-
-/**
- * {@link MailQueueFactory} implementations which return
- * {@link ActiveMQCacheableMailQueue} instances
- */
-public class ActiveMQMailQueueFactory extends JMSMailQueueFactory {
-
- private boolean useBlob = true;
-
- private final ActiveMQMetricCollector activeMQMetricCollector;
-
- public ActiveMQMailQueueFactory(ConnectionFactory connectionFactory, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, MetricFactory metricFactory,
- GaugeRegistry gaugeRegistry, ActiveMQMetricCollector activeMQMetricCollector) {
- super(connectionFactory, mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry);
- this.activeMQMetricCollector = activeMQMetricCollector;
- }
-
- @Inject
- public ActiveMQMailQueueFactory(EmbeddedActiveMQ embeddedActiveMQ, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, MetricFactory metricFactory,
- GaugeRegistry gaugeRegistry, ActiveMQMetricCollector activeMQMetricCollector) {
- this(embeddedActiveMQ.getConnectionFactory(), mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry, activeMQMetricCollector);
- }
-
- public void setUseBlobMessages(boolean useBlob) {
- this.useBlob = useBlob;
- }
-
- @Override
- protected ManageableMailQueue createCacheableMailQueue(MailQueueName name) {
- activeMQMetricCollector.collectQueueStatistics(name);
- return new ActiveMQCacheableMailQueue(connectionFactory, mailQueueItemDecoratorFactory, name, useBlob, metricFactory, gaugeRegistry);
- }
-}
+/****************************************************************
+ * 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.activemq;
+
+import jakarta.inject.Inject;
+import jakarta.jms.ConnectionFactory;
+
+import org.apache.james.metrics.api.GaugeRegistry;
+import org.apache.james.metrics.api.MetricFactory;
+import org.apache.james.queue.activemq.metric.ActiveMQMetricCollector;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.james.queue.api.MailQueueName;
+import org.apache.james.queue.api.ManageableMailQueue;
+import org.apache.james.queue.jms.JMSCacheableMailQueue;
+import org.apache.james.queue.jms.JMSMailQueueFactory;
+
+/**
+ * {@link MailQueueFactory} implementation backed by Apache ActiveMQ Artemis.
+ */
+public class ActiveMQMailQueueFactory extends JMSMailQueueFactory {
+
+ private final ActiveMQMetricCollector activeMQMetricCollector;
+
+ public ActiveMQMailQueueFactory(ConnectionFactory connectionFactory, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, MetricFactory metricFactory,
+ GaugeRegistry gaugeRegistry, ActiveMQMetricCollector activeMQMetricCollector) {
+ super(connectionFactory, mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry);
+ this.activeMQMetricCollector = activeMQMetricCollector;
+ }
+
+ @Inject
+ public ActiveMQMailQueueFactory(EmbeddedActiveMQ embeddedActiveMQ, MailQueueItemDecoratorFactory mailQueueItemDecoratorFactory, MetricFactory metricFactory,
+ GaugeRegistry gaugeRegistry, ActiveMQMetricCollector activeMQMetricCollector) {
+ this(embeddedActiveMQ.getConnectionFactory(), mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry, activeMQMetricCollector);
+ }
+
+ @Override
+ protected ManageableMailQueue createCacheableMailQueue(MailQueueName name) {
+ activeMQMetricCollector.collectQueueStatistics(name);
+ return new JMSCacheableMailQueue(connectionFactory, mailQueueItemDecoratorFactory, name, metricFactory, gaugeRegistry);
+ }
+}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueItem.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueItem.java
deleted file mode 100644
index 6c5197caa4..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQMailQueueItem.java
+++ /dev/null
@@ -1,70 +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.queue.activemq;
-
-import java.io.IOException;
-
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.Session;
-
-import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.james.queue.api.MailQueue.MailQueueException;
-import org.apache.james.queue.api.MailQueue.MailQueueItem;
-import org.apache.james.queue.jms.JMSMailQueueItem;
-import org.apache.mailet.Mail;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * ActiveMQ {@link MailQueueItem} implementation which handles Blob-Messages as
- * well
- */
-public class ActiveMQMailQueueItem extends JMSMailQueueItem implements ActiveMQSupport {
- private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQMailQueueItem.class);
-
- private final Message message;
-
- public ActiveMQMailQueueItem(Mail mail, Session session, MessageConsumer consumer, Message message) {
- super(mail, session, consumer);
- this.message = message;
- }
-
- @Override
- public void done(CompletionStatus success) throws MailQueueException {
- super.done(success);
- if (success == CompletionStatus.SUCCESS) {
- if (message instanceof ActiveMQBlobMessage && !getMail().getAttribute(JAMES_REUSE_BLOB_URL).isPresent()) {
-
- // This should get removed once this jira issue was fixed
- // https://issues.apache.org/activemq/browse/AMQ-1529
- try {
- ((ActiveMQBlobMessage) message).deleteFile();
- } catch (IOException | JMSException e) {
- LOGGER.warn("Unable to delete blob message file for mail {}", getMail().getName(), e);
- }
- }
- getMail().removeAttribute(JAMES_REUSE_BLOB_URL);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQSupport.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQSupport.java
deleted file mode 100644
index a2c4da1c06..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/ActiveMQSupport.java
+++ /dev/null
@@ -1,44 +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.queue.activemq;
-
-import org.apache.james.queue.jms.JMSSupport;
-import org.apache.mailet.AttributeName;
-
-/**
- * Interface which should get implemented by ActiveMQ depending implementions
- */
-public interface ActiveMQSupport extends JMSSupport {
-
- /**
- * The name of the Queue the mail is stored in
- */
- AttributeName JAMES_QUEUE_NAME = AttributeName.of("JAMES_QUEUE_NAME");
-
- /**
- * The URL of the Blobmessage content
- */
- AttributeName JAMES_BLOB_URL = AttributeName.of("JAMES_BLOB_URL");
-
- /**
- * Indicate that the Blobmessage content is reused for a new message
- */
- AttributeName JAMES_REUSE_BLOB_URL = AttributeName.of(" JAMES_REUSE_BLOB_URL");
-
-}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
index ac6f1d9558..98d9cd8c8d 100644
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
+++ b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/EmbeddedActiveMQ.java
@@ -23,107 +23,87 @@ import jakarta.annotation.PreDestroy;
import jakarta.inject.Inject;
import jakarta.jms.ConnectionFactory;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.blob.BlobTransferPolicy;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.jmx.ManagementContext;
-import org.apache.activemq.plugin.StatisticsBrokerPlugin;
-import org.apache.activemq.store.PersistenceAdapter;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.james.filesystem.api.FileSystem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Embedded Artemis broker replacing the legacy ActiveMQ embedded broker.
+ * Uses Apache ActiveMQ Artemis (Jakarta JMS) as the underlying message broker.
+ */
public class EmbeddedActiveMQ {
private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedActiveMQ.class);
- private static final String KAHADB_STORE_LOCATION = "file://var/store/activemq/brokers/KahaDB";
- private static final String BLOB_TRANSFER_LOCATION = "file://var/store/activemq/blob-transfer";
- private static final String BROCKERS_LOCATION = "file://var/store/activemq/brokers";
- private static final String BROKER_ID = "broker";
+ private static final String DATA_DIRECTORY_RELATIVE = "var/store/artemis";
private static final String BROKER_NAME = "james";
- private static final String BROCKER_URI = "tcp://localhost:0";
- private static final String STORE_USAGE_LIMIT_PROPERTY = "james.activemq.store.usage.limit.bytes";
- private static final String TEMP_USAGE_LIMIT_PROPERTY = "james.activemq.temp.usage.limit.bytes";
- private static final long DEFAULT_STORE_USAGE_LIMIT_BYTES = 10L * 1024 * 1024 * 1024; // 10 GB
- private static final long DEFAULT_TEMP_USAGE_LIMIT_BYTES = 5L * 1024 * 1024 * 1024; // 5 GB
- private final ActiveMQConnectionFactory activeMQConnectionFactory;
- private final PersistenceAdapter persistenceAdapter;
- private BrokerService brokerService;
+ private final ActiveMQConnectionFactory connectionFactory;
+ private final org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ embeddedServer;
@Inject
- private EmbeddedActiveMQ(FileSystem fileSystem, PersistenceAdapter persistenceAdapter, ActiveMQConfiguration configuration) {
- this.persistenceAdapter = persistenceAdapter;
+ public EmbeddedActiveMQ(FileSystem fileSystem, ActiveMQConfiguration configuration) {
try {
- persistenceAdapter.setDirectory(fileSystem.getFile(KAHADB_STORE_LOCATION));
- launchEmbeddedBroker(fileSystem, configuration);
+ String dataDirectory = fileSystem.getFile("file://" + DATA_DIRECTORY_RELATIVE).getAbsolutePath();
+ embeddedServer = createAndStartBroker(dataDirectory, configuration);
+ connectionFactory = createConnectionFactory(configuration);
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new RuntimeException("Failed to start embedded Artemis broker", e);
}
- activeMQConnectionFactory = createActiveMQConnectionFactory(createBlobTransferPolicy(fileSystem));
}
public ConnectionFactory getConnectionFactory() {
- return activeMQConnectionFactory;
+ return connectionFactory;
}
@PreDestroy
public void stop() throws Exception {
- LOGGER.info("Stopping embedded ActiveMQ...");
- brokerService.stop();
- LOGGER.info("Stopped embedded ActiveMQ");
+ LOGGER.info("Stopping embedded Artemis broker...");
+ embeddedServer.stop();
+ connectionFactory.close();
+ LOGGER.info("Stopped embedded Artemis broker");
}
- private ActiveMQConnectionFactory createActiveMQConnectionFactory(BlobTransferPolicy blobTransferPolicy) {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://james?create=false");
- connectionFactory.setTrustAllPackages(false);
- connectionFactory.setBlobTransferPolicy(blobTransferPolicy);
- connectionFactory.setPrefetchPolicy(createActiveMQPrefetchPolicy());
- return connectionFactory;
- }
-
- private ActiveMQPrefetchPolicy createActiveMQPrefetchPolicy() {
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- prefetchPolicy.setTopicPrefetch(0);
- return prefetchPolicy;
- }
+ private org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ createAndStartBroker(String dataDirectory,
+ ActiveMQConfiguration configuration) throws Exception {
+ Configuration config = new ConfigurationImpl()
+ .setSecurityEnabled(false)
+ .setJMXManagementEnabled(false)
+ .setPersistenceEnabled(true)
+ .setJournalDirectory(dataDirectory + "/journal")
+ .setBindingsDirectory(dataDirectory + "/bindings")
+ .setLargeMessagesDirectory(dataDirectory + "/largemessages")
+ .setPagingDirectory(dataDirectory + "/paging")
+ .setJournalSyncTransactional(configuration.isJournalSyncTransactional())
+ .setJournalSyncNonTransactional(configuration.isJournalSyncNonTransactional())
+ .setJournalBufferTimeout_NIO(configuration.getJournalBufferTimeoutNIO())
+ .setJournalBufferSize_NIO(configuration.getJournalBufferSizeNIO())
+ .setJournalMaxIO_NIO(configuration.getJournalMaxIONIO())
+ .setEnabledAsyncConnectionExecution(configuration.isAsyncConnectionExecution())
+ .addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()))
+ .setName(BROKER_NAME);
- private BlobTransferPolicy createBlobTransferPolicy(FileSystem fileSystem) {
- FileSystemBlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy();
- blobTransferPolicy.setDefaultUploadUrl(BLOB_TRANSFER_LOCATION);
- blobTransferPolicy.setFileSystem(fileSystem);
- return blobTransferPolicy;
+ org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ server = new org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ();
+ server.setConfiguration(config);
+ server.start();
+ LOGGER.info("Started embedded Artemis broker (bufferTimeout: {} ns, bufferSize: {} bytes, syncTx: {}, syncNonTx: {}), data directory: {}",
+ configuration.getJournalBufferTimeoutNIO(), configuration.getJournalBufferSizeNIO(),
+ configuration.isJournalSyncTransactional(), configuration.isJournalSyncNonTransactional(),
+ dataDirectory);
+ return server;
}
- private void launchEmbeddedBroker(FileSystem fileSystem, ActiveMQConfiguration configuration) throws Exception {
- brokerService = new BrokerService();
- brokerService.setBrokerName(BROKER_NAME);
- brokerService.setUseJmx(false);
- brokerService.setPersistent(true);
- brokerService.setDataDirectoryFile(fileSystem.getFile(BROCKERS_LOCATION));
- brokerService.setUseShutdownHook(false);
- brokerService.setSchedulerSupport(false);
- brokerService.setAdjustUsageLimits(configuration.isAdjustUsageLimits());
- long storeUsageLimitBytes = Long.getLong(STORE_USAGE_LIMIT_PROPERTY, DEFAULT_STORE_USAGE_LIMIT_BYTES);
- long tempUsageLimitBytes = Long.getLong(TEMP_USAGE_LIMIT_PROPERTY, DEFAULT_TEMP_USAGE_LIMIT_BYTES);
- brokerService.getSystemUsage().getStoreUsage().setLimit(storeUsageLimitBytes);
- brokerService.getSystemUsage().getTempUsage().setLimit(tempUsageLimitBytes);
- brokerService.setBrokerId(BROKER_ID);
- String[] uris = {BROCKER_URI};
- brokerService.setTransportConnectorURIs(uris);
- ManagementContext managementContext = new ManagementContext();
- managementContext.setCreateConnector(false);
- brokerService.setManagementContext(managementContext);
- brokerService.setPersistenceAdapter(persistenceAdapter);
- BrokerPlugin[] brokerPlugins = {new StatisticsBrokerPlugin()};
- brokerService.setPlugins(brokerPlugins);
- brokerService.setEnableStatistics(true);
- String[] transportConnectorsURIs = {BROCKER_URI};
- brokerService.setTransportConnectorURIs(transportConnectorsURIs);
- brokerService.start();
- LOGGER.info("Started embedded ActiveMQ");
+ private ActiveMQConnectionFactory createConnectionFactory(ActiveMQConfiguration configuration) {
+ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(
+ "vm://0?broker-name=" + BROKER_NAME
+ );
+ factory.setConsumerWindowSize(0);
+ factory.setBlockOnAcknowledge(configuration.isClientBlockOnAcknowledge());
+ factory.setBlockOnDurableSend(configuration.isClientBlockOnDurableSend());
+ return factory;
}
}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
deleted file mode 100644
index dff022e6c5..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobStrategy.java
+++ /dev/null
@@ -1,135 +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.queue.activemq;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.SecureRandom;
-import java.util.regex.Pattern;
-
-import jakarta.jms.JMSException;
-
-import org.apache.activemq.BlobMessage;
-import org.apache.activemq.blob.BlobDownloadStrategy;
-import org.apache.activemq.blob.BlobTransferPolicy;
-import org.apache.activemq.blob.BlobUploadStrategy;
-import org.apache.activemq.command.ActiveMQBlobMessage;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.james.filesystem.api.FileSystem;
-
-/**
- * {@link BlobUploadStrategy} and {@link BlobDownloadStrategy} implementation
- * which use the {@link FileSystem} to lookup the {@link File} for the
- * {@link BlobMessage}
- */
-public class FileSystemBlobStrategy implements BlobUploadStrategy, BlobDownloadStrategy, ActiveMQSupport {
- private static final Pattern PATTERN = Pattern.compile("[:\\\\/*?|<>]");
- private static final SecureRandom RANDOM = new SecureRandom();
-
- private final FileSystem fileSystem;
- private final BlobTransferPolicy policy;
- private final int splitCount;
- private final Object lock = new Object();
-
- public FileSystemBlobStrategy(BlobTransferPolicy policy, FileSystem fileSystem, int splitCount) {
- this.fileSystem = fileSystem;
- this.policy = policy;
- this.splitCount = splitCount;
- }
-
- @Override
- public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException {
- try (FileInputStream in = new FileInputStream(file)) {
- return uploadStream(message, in);
- }
- }
-
- @Override
- public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException {
- File f = getFile(message);
- try (FileOutputStream out = new FileOutputStream(f)) {
- IOUtils.copy(in, out, policy.getBufferSize());
- out.flush();
- // File.toURL() is deprecated
- return f.toURI().toURL();
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // ignore on close
- }
- }
- }
- }
-
- @Override
- public void deleteFile(ActiveMQBlobMessage message) throws IOException, JMSException {
- File f = getFile(message);
- synchronized (lock) {
- FileUtils.forceDelete(f);
- }
- }
-
- /**
- * Returns a {@link FileInputStream} for the give {@link BlobMessage}
- */
- @Override
- public InputStream getInputStream(ActiveMQBlobMessage message) throws IOException, JMSException {
- return new FileInputStream(getFile(message));
- }
-
- /**
- * Return the {@link File} for the {@link ActiveMQBlobMessage}. The
- * {@link File} is lookup via the {@link FileSystem} service
- *
- * @param message
- * @return file
- * @throws JMSException
- * @throws FileNotFoundException
- */
- protected File getFile(ActiveMQBlobMessage message) throws JMSException, IOException {
- if (message.getURL() != null) {
- return fileSystem.getFile(message.getURL().toString());
- }
-
- // Make sure it works on windows in all cases and make sure
- // we use the JMS Message ID as filename so we are safe in the case
- // we try to stream from and to the same mail
- String filename = PATTERN.matcher(message.getJMSMessageID()).replaceAll("_");
- int i = RANDOM.nextInt(splitCount) + 1;
-
- String queueUrl = policy.getUploadUrl() + "/" + i;
-
- File queueF = fileSystem.getFile(queueUrl);
-
- synchronized (lock) {
- // check if we need to create the queue folder
- FileUtils.forceMkdir(queueF);
- }
-
- return fileSystem.getFile(queueUrl + "/" + filename);
- }
-}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobTransferPolicy.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobTransferPolicy.java
deleted file mode 100644
index 9a0a1c1b2e..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/FileSystemBlobTransferPolicy.java
+++ /dev/null
@@ -1,75 +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.queue.activemq;
-
-import jakarta.inject.Inject;
-
-import org.apache.activemq.blob.BlobDownloadStrategy;
-import org.apache.activemq.blob.BlobTransferPolicy;
-import org.apache.activemq.blob.BlobUploadStrategy;
-import org.apache.james.filesystem.api.FileSystem;
-
-/**
- * {@link BlobTransferPolicy} which use the {@link FileSystem} to download and
- * upload data. So this implementation is only useful when using a non-clustered
- * ActiveMQ Broker or when using a shared Storage for the files.
- */
-public class FileSystemBlobTransferPolicy extends BlobTransferPolicy {
-
- private FileSystem fileSystem;
- private int splitCount = 10;
- private FileSystemBlobStrategy strategy;
-
- @Inject
- public void setFileSystem(FileSystem fileSystem) {
- this.fileSystem = fileSystem;
- }
-
- public void setSplitCount(int splitCount) {
- this.splitCount = splitCount;
- }
-
- @Override
- public BlobTransferPolicy copy() {
- FileSystemBlobTransferPolicy that = new FileSystemBlobTransferPolicy();
- that.setFileSystem(fileSystem);
- that.setDefaultUploadUrl(getDefaultUploadUrl());
- that.setBrokerUploadUrl(getBrokerUploadUrl());
- that.setUploadUrl(getUploadUrl());
- that.setUploadStrategy(getUploadStrategy());
- return that;
- }
-
- @Override
- protected BlobDownloadStrategy createDownloadStrategy() {
- return getStrategy();
- }
-
- @Override
- protected BlobUploadStrategy createUploadStrategy() {
- return getStrategy();
- }
-
- private synchronized FileSystemBlobStrategy getStrategy() {
- if (strategy == null) {
- strategy = new FileSystemBlobStrategy(this, fileSystem, splitCount);
- }
- return strategy;
- }
-}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
deleted file mode 100644
index 39f5808440..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/MimeMessageBlobMessageSource.java
+++ /dev/null
@@ -1,72 +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.queue.activemq;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import jakarta.jms.JMSException;
-
-import org.apache.activemq.BlobMessage;
-import org.apache.james.server.core.MimeMessageSource;
-
-/**
- *
- */
-public class MimeMessageBlobMessageSource implements MimeMessageSource, ActiveMQSupport {
-
- private final String sourceId;
- private final BlobMessage message;
-
- public MimeMessageBlobMessageSource(BlobMessage message) throws JMSException {
- this.message = message;
- this.sourceId = message.getJMSMessageID();
- }
-
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- return message.getInputStream();
- } catch (JMSException e) {
- throw new IOException("Unable to open stream", e);
- }
- }
-
- @Override
- public String getSourceId() {
- return sourceId;
- }
-
- @Override
- public long getMessageSize() throws IOException {
- try {
- long size = message.getLongProperty(JAMES_MAIL_MESSAGE_SIZE);
-
- // if the size is < 1 we seems to not had it stored in the property, so
- // fallback to super implementation
- if (size == -1) {
- MimeMessageSource.super.getMessageSize();
- }
- return size;
- } catch (JMSException e) {
- throw new IOException("Unable to get message size", e);
- }
-
- }
-}
diff --git a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java b/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java
deleted file mode 100644
index 74cdc0d012..0000000000
--- a/server/queue/queue-activemq/src/main/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorImpl.java
+++ /dev/null
@@ -1,202 +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.queue.activemq.metric;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import jakarta.annotation.PreDestroy;
-import jakarta.inject.Inject;
-import jakarta.jms.Connection;
-import jakarta.jms.ConnectionFactory;
-import jakarta.jms.JMSException;
-import jakarta.jms.MapMessage;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.Queue;
-import jakarta.jms.Session;
-import jakarta.jms.TemporaryQueue;
-
-import org.apache.james.metrics.api.GaugeRegistry;
-import org.apache.james.metrics.api.MetricFactory;
-import org.apache.james.queue.activemq.ActiveMQConfiguration;
-import org.apache.james.queue.api.MailQueueName;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import reactor.core.Disposable;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-import reactor.core.scheduler.Schedulers;
-
-public class ActiveMQMetricCollectorImpl implements ActiveMQMetricCollector {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQMetricCollectorImpl.class);
-
- private final ActiveMQMetricConfiguration config;
- private final ConnectionFactory connectionFactory;
- private final MetricFactory metricFactory;
- private final GaugeRegistry gaugeRegistry;
-
- private final Map<String, ActiveMQMetrics> registeredStatistics = new HashMap<>();
-
- private Disposable disposable;
-
- @Inject
- public ActiveMQMetricCollectorImpl(ActiveMQConfiguration activeMQConfiguration, ConnectionFactory connectionFactory, MetricFactory metricFactory, GaugeRegistry gaugeRegistry) {
- this.config = activeMQConfiguration.getMetricConfiguration();
- this.connectionFactory = connectionFactory;
- this.metricFactory = metricFactory;
- this.gaugeRegistry = gaugeRegistry;
- }
-
- @Override
- public void collectBrokerStatistics() {
- collectStatistics(ActiveMQMetrics.forBroker(gaugeRegistry));
- }
-
- @Override
- public void collectQueueStatistics(MailQueueName name) {
- collectStatistics(ActiveMQMetrics.forQueue(name.asString(), gaugeRegistry));
- }
-
- private void collectStatistics(ActiveMQMetrics statistics) {
- if (config.isEnabled() && !registeredStatistics.containsKey(statistics.getName())) {
- LOGGER.info("collecting statistics for {}", statistics.getName());
- registeredStatistics.put(statistics.getName(), statistics);
- }
- }
-
- @Override
- public void start() {
- if (!config.isEnabled()) {
- LOGGER.info("collecting statistics disabled");
- return;
- }
-
- collectBrokerStatistics();
-
- LOGGER.info("start delay={} interval={} timeout={} aqmp_timeout={}",
- config.getStartDelay(), config.getInterval(), config.getTimeout(), config.getAqmpTimeout());
-
- disposable = Flux.interval(config.getStartDelay(), config.getInterval())
- .flatMap(any -> Flux.fromStream(() -> registeredStatistics.values().stream())
- .flatMap((s) -> {
- Mono<Void> task = Mono.fromCallable(() -> fetchAndUpdate(s)).timeout(config.getTimeout());
- return metricFactory.decoratePublisherWithTimerMetric(s.getName() + "._time", task);
- })
- )
- .onErrorContinue(this::logError)
- .subscribeOn(Schedulers.newSingle(ActiveMQMetricCollectorImpl.class.getSimpleName()))
- .subscribe();
- }
-
- @Override
- @PreDestroy
- public void stop() {
- disposable.dispose();
- }
-
- private Void logError(Throwable error, Object triggeringValue) {
- LOGGER.warn("failed to fetch and update broker statistics", error);
- return null;
- }
-
- @VisibleForTesting
- Void fetchAndUpdate(ActiveMQMetrics stats) throws JMSException {
- Connection connection = null;
- Session session = null;
- TemporaryQueue replyTo = null;
- MessageConsumer consumer = null;
- MessageProducer producer = null;
- try {
- connection = connectionFactory.createConnection();
- connection.start();
- session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- replyTo = session.createTemporaryQueue();
- consumer = session.createConsumer(replyTo);
-
- Queue testQueue = session.createQueue(stats.getName());
- producer = session.createProducer(testQueue);
- Message msg = session.createMessage();
- msg.setJMSReplyTo(replyTo);
- producer.send(msg);
-
- long timeoutMs = config.getAqmpTimeout().toMillis();
- Message reply = consumer.receive(timeoutMs);
- if (reply == null) {
- throw new JMSException("no message received, timed out after " + timeoutMs + " ms");
- } else if (!(reply instanceof MapMessage)) {
- throw new JMSException("expected MapMessage but got " + reply.getClass());
- }
- stats.updateMetrics((MapMessage)reply);
- } finally {
- if (producer != null) {
- try {
- producer.close();
- } catch (JMSException e) {
- // ignore
- }
- }
-
- if (consumer != null) {
- try {
- consumer.close();
- } catch (JMSException e) {
- // ignore
- }
- }
-
- if (replyTo != null) {
- // we need to delete the temporary queue to be sure we will
- // free up memory if thats not done and a pool is used
- // its possible that we will register a new mbean in jmx for
- // every TemporaryQueue which will never get unregistered
- try {
- replyTo.delete();
- } catch (JMSException e) {
- // ignore
- }
- }
-
- if (session != null) {
- try {
- session.close();
- } catch (JMSException e) {
- // ignore
- }
- }
-
- if (connection != null) {
- try {
- connection.close();
- } catch (JMSException e) {
- // ignore
- }
- }
- }
- return null;
- }
-
-}
diff --git a/server/queue/queue-activemq/src/main/resources/META-INF/spring/activemq-queue-context.xml b/server/queue/queue-activemq/src/main/resources/META-INF/spring/activemq-queue-context.xml
index d411786dce..83239c3071 100644
--- a/server/queue/queue-activemq/src/main/resources/META-INF/spring/activemq-queue-context.xml
+++ b/server/queue/queue-activemq/src/main/resources/META-INF/spring/activemq-queue-context.xml
@@ -1,45 +1,47 @@
-<?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. !
--->
-
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
-
- <!-- James Mail Queue Factory -->
- <bean id="mailqueuefactory" class="org.apache.james.queue.activemq.ActiveMQMailQueueFactory">
- <constructor-arg index="0" ref="embeddedActiveMQ"/>
- <constructor-arg index="1" ref="rawMailQueueItemDecoratorFactory"/>
- <constructor-arg index="2" ref="metricFactory"/>
- <constructor-arg index="3" ref="gaugeRegistry"/>
- <constructor-arg index="4" ref="activeMQMetricCollector"/>
- </bean>
-
- <bean id="rawMailQueueItemDecoratorFactory" class="org.apache.james.queue.api.RawMailQueueItemDecoratorFactory"/>
-
- <bean id="embeddedActiveMQ" class="org.apache.james.queue.activemq.EmbeddedActiveMQ">
- <constructor-arg index="0" ref="filesystem"/>
- <constructor-arg index="1" ref="persistenceAdapter"/>
- <constructor-arg index="2" ref="configuration"/>
- </bean>
-
- <bean id="persistenceAdapter" class="org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter"/>
-
- <bean id="activeMQMetricCollector" class="org.apache.james.queue.activemq.metric.ActiveMQMetricCollectorNoop"/>
-
- <bean id="configuration" class="org.apache.james.queue.activemq.ActiveMQConfiguration" factory-method="getDefault"/>
-</beans>
+<?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. !
+-->
+
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <!-- James Mail Queue Factory (backed by embedded Artemis broker) -->
+ <bean id="mailqueuefactory" class="org.apache.james.queue.activemq.ActiveMQMailQueueFactory">
+ <constructor-arg index="0" ref="embeddedActiveMQ"/>
+ <constructor-arg index="1" ref="rawMailQueueItemDecoratorFactory"/>
+ <constructor-arg index="2" ref="metricFactory"/>
+ <constructor-arg index="3" ref="gaugeRegistry"/>
+ <constructor-arg index="4" ref="activeMQMetricCollector"/>
+ </bean>
+
+ <bean id="rawMailQueueItemDecoratorFactory" class="org.apache.james.queue.api.RawMailQueueItemDecoratorFactory"/>
+
+ <!--
+ Embedded Artemis broker replaces the legacy ActiveMQ BrokerService.
+ Constructor args: FileSystem, ActiveMQConfiguration
+ (PersistenceAdapter removed - Artemis uses its own journal)
+ -->
+ <bean id="embeddedActiveMQ" class="org.apache.james.queue.activemq.EmbeddedActiveMQ">
+ <constructor-arg index="0" ref="filesystem"/>
+ <constructor-arg index="1" ref="activemqConfiguration"/>
+ </bean>
+
+ <bean id="activeMQMetricCollector" class="org.apache.james.queue.activemq.metric.ActiveMQMetricCollectorNoop"/>
+
+ <bean id="activemqConfiguration" class="org.apache.james.queue.activemq.ActiveMQConfiguration" factory-method="getDefault"/>
+</beans>
diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQHealthCheckTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQHealthCheckTest.java
index ee3ecfd708..8b0d6eb735 100644
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQHealthCheckTest.java
+++ b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQHealthCheckTest.java
@@ -22,9 +22,8 @@ package org.apache.james.queue.activemq;
import static org.apache.james.queue.activemq.ActiveMQHealthCheck.COMPONENT_NAME;
import static org.assertj.core.api.Assertions.assertThat;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.james.core.healthcheck.Result;
import org.apache.james.queue.jms.BrokerExtension;
import org.junit.jupiter.api.BeforeEach;
@@ -37,16 +36,13 @@ import reactor.core.publisher.Mono;
class ActiveMQHealthCheckTest {
private ActiveMQHealthCheck testee;
- private BrokerService broker;
+ private EmbeddedActiveMQ broker;
@BeforeEach
- void setup(BrokerService broker) {
+ void setup(EmbeddedActiveMQ broker) {
this.broker = broker;
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- connectionFactory.setPrefetchPolicy(prefetchPolicy);
-
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://0");
+ connectionFactory.setConsumerWindowSize(0);
testee = new ActiveMQHealthCheck(connectionFactory);
}
@@ -68,4 +64,3 @@ class ActiveMQHealthCheckTest {
assertThat(Mono.from(testee.check()).block().isUnHealthy()).isTrue();
}
}
-
diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java
deleted file mode 100644
index c7abe08db0..0000000000
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueBlobTest.java
+++ /dev/null
@@ -1,213 +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.queue.activemq;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.time.temporal.ChronoUnit;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.commons.io.FileUtils;
-import org.apache.james.filesystem.api.FileSystem;
-import org.apache.james.metrics.api.GaugeRegistry;
-import org.apache.james.metrics.api.MetricFactory;
-import org.apache.james.queue.api.DelayedManageableMailQueueContract;
-import org.apache.james.queue.api.DelayedPriorityMailQueueContract;
-import org.apache.james.queue.api.MailQueue;
-import org.apache.james.queue.api.MailQueueMetricContract;
-import org.apache.james.queue.api.MailQueueMetricExtension;
-import org.apache.james.queue.api.MailQueueName;
-import org.apache.james.queue.api.ManageableMailQueue;
-import org.apache.james.queue.api.PriorityManageableMailQueueContract;
-import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
-import org.apache.james.queue.jms.BrokerExtension;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@ExtendWith(BrokerExtension.class)
-@Tag(BrokerExtension.STATISTICS)
-public class ActiveMQMailQueueBlobTest implements DelayedManageableMailQueueContract, DelayedPriorityMailQueueContract, PriorityManageableMailQueueContract,
- MailQueueMetricContract {
-
- static final String BASE_DIR = "file://target/james-test";
- static final boolean USE_BLOB = true;
-
- ActiveMQCacheableMailQueue mailQueue;
- MyFileSystem fileSystem;
-
- @BeforeEach
- public void setUp(BrokerService broker, MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) {
- fileSystem = new MyFileSystem();
- ActiveMQConnectionFactory connectionFactory = createConnectionFactory();
- connectionFactory.setTrustAllPackages(false);
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- connectionFactory.setPrefetchPolicy(prefetchPolicy);
- FileSystemBlobTransferPolicy policy = new FileSystemBlobTransferPolicy();
- policy.setFileSystem(fileSystem);
- policy.setDefaultUploadUrl(BASE_DIR);
- connectionFactory.setBlobTransferPolicy(policy);
-
- RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
- MetricFactory metricFactory = metricTestSystem.getMetricFactory();
- GaugeRegistry gaugeRegistry = metricTestSystem.getSpyGaugeRegistry();
- MailQueueName queueName = BrokerExtension.generateRandomQueueName(broker);
- mailQueue = new ActiveMQCacheableMailQueue(connectionFactory, mailQueueItemDecoratorFactory, queueName, USE_BLOB, metricFactory, gaugeRegistry);
- }
-
- @AfterEach
- public void tearDown() {
- mailQueue.dispose();
- fileSystem.destroy();
- }
-
- @Override
- public MailQueue getMailQueue() {
- return mailQueue;
- }
-
- @Override
- public ManageableMailQueue getManageableMailQueue() {
- return mailQueue;
- }
-
- @Test
- @Override
- @Disabled("JAMES-2295 Disabled as test was dead-locking")
- public void dequeueCanBeChainedBeforeAck() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-2295 Disabled as test was dead-locking")
- public void dequeueCouldBeInterleavingWithOutOfOrderAck() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-2308 Flushing JMS mail queue randomly re-order them" +
- "Random test failing around 1% of the time")
- public void flushShouldPreserveBrowseOrder() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-2312 JMS clear mailqueue can ommit some messages" +
- "Random test failing around 1% of the time")
- public void clearShouldRemoveAllElements() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-2544 Mixing concurrent ack/nack might lead to a deadlock")
- public void concurrentEnqueueDequeueWithAckNackShouldNotFail() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-2794 This test never finishes")
- public void enQueueShouldAcceptMailWithDuplicatedNames() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-3687 Delayed deletes are buggy")
- public void delayedEmailsShouldBeDeleted() {
-
- }
-
- @Test
- @Override
- @Disabled("JAMES-3687 Delayed deletes are buggy")
- public void delayedEmailsShouldBeDeletedWhenMixedWithOtherEmails() {
-
- }
-
- @Test
- void computeNextDeliveryTimestampShouldReturnLongMaxWhenOverflow() {
- long deliveryTimestamp = mailQueue.computeNextDeliveryTimestamp(ChronoUnit.FOREVER.getDuration());
-
- assertThat(deliveryTimestamp).isEqualTo(Long.MAX_VALUE);
- }
-
- protected ActiveMQConnectionFactory createConnectionFactory() {
- ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?create=false");
-
- FileSystemBlobTransferPolicy policy = new FileSystemBlobTransferPolicy();
- policy.setFileSystem(new MyFileSystem());
- policy.setDefaultUploadUrl(BASE_DIR);
- factory.setBlobTransferPolicy(policy);
-
- return factory;
- }
-
- public static final class MyFileSystem implements FileSystem {
- private static final Logger LOGGER = LoggerFactory.getLogger(MyFileSystem.class);
-
- @Override
- public InputStream getResource(String url) {
- return null;
- }
-
- @Override
- public File getFile(String fileURL) throws FileNotFoundException {
- if (fileURL.startsWith("file://")) {
- return new File(fileURL.substring("file://".length()));
-
- } else if (fileURL.startsWith("file:/")) {
- return new File(fileURL.substring("file:".length()));
-
- }
- throw new FileNotFoundException();
- }
-
- @Override
- public File getBasedir() throws FileNotFoundException {
- throw new FileNotFoundException();
- }
-
- public void destroy() {
- try {
- FileUtils.forceDelete(getFile(BASE_DIR));
- } catch (FileNotFoundException e) {
- LOGGER.info("No file specified");
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- }
-}
diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactoryTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactoryTest.java
index a6ed1e79b0..a9e9178768 100644
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactoryTest.java
+++ b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueFactoryTest.java
@@ -21,8 +21,8 @@ package org.apache.james.queue.activemq;
import jakarta.jms.ConnectionFactory;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.james.metrics.api.NoopGaugeRegistry;
import org.apache.james.metrics.tests.RecordingMetricFactory;
import org.apache.james.queue.activemq.metric.ActiveMQMetricCollector;
@@ -46,15 +46,14 @@ public class ActiveMQMailQueueFactoryTest {
ActiveMQMailQueueFactory mailQueueFactory;
@BeforeEach
- public void setUp(BrokerService brokerService) {
- ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
+ public void setUp(EmbeddedActiveMQ brokerService) {
+ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://0");
RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
RecordingMetricFactory metricFactory = new RecordingMetricFactory();
NoopGaugeRegistry gaugeRegistry = new NoopGaugeRegistry();
ActiveMQMetricCollector metricCollector = new ActiveMQMetricCollectorNoop();
mailQueueFactory = new ActiveMQMailQueueFactory(connectionFactory, mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry, metricCollector);
mailQueueFactory.setUseJMX(false);
- mailQueueFactory.setUseBlobMessages(false);
}
@AfterEach
@@ -68,25 +67,21 @@ public class ActiveMQMailQueueFactoryTest {
}
}
+ /**
+ * Blob-based test is kept as a nested class but now uses standard Artemis JMS.
+ * BlobMessages are not supported in Artemis; this test exercises the same queue
+ * using ObjectMessage transport (the new default).
+ */
@Nested
@ExtendWith(BrokerExtension.class)
public static class ActiveMQMailQueueFactoryBlobsTest implements MailQueueFactoryContract<ManageableMailQueue>, ManageableMailQueueFactoryContract {
- static final String BASE_DIR = "file://target/james-test";
-
ActiveMQMailQueueFactory mailQueueFactory;
- ActiveMQMailQueueBlobTest.MyFileSystem fileSystem;
@BeforeEach
- public void setUp(BrokerService brokerService) {
- fileSystem = new ActiveMQMailQueueBlobTest.MyFileSystem();
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
-
-
- FileSystemBlobTransferPolicy policy = new FileSystemBlobTransferPolicy();
- policy.setFileSystem(fileSystem);
- policy.setDefaultUploadUrl(BASE_DIR);
- connectionFactory.setBlobTransferPolicy(policy);
+ public void setUp(EmbeddedActiveMQ brokerService) {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://0");
+ connectionFactory.setConsumerWindowSize(0);
RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
RecordingMetricFactory metricFactory = new RecordingMetricFactory();
@@ -94,13 +89,11 @@ public class ActiveMQMailQueueFactoryTest {
ActiveMQMetricCollector metricCollector = new ActiveMQMetricCollectorNoop();
mailQueueFactory = new ActiveMQMailQueueFactory(connectionFactory, mailQueueItemDecoratorFactory, metricFactory, gaugeRegistry, metricCollector);
mailQueueFactory.setUseJMX(false);
- mailQueueFactory.setUseBlobMessages(true);
}
@AfterEach
- public void tearDown() throws Exception {
+ public void tearDown() {
mailQueueFactory.destroy();
- fileSystem.destroy();
}
@Override
diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
index 7711dace06..88ac42357c 100644
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
+++ b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/ActiveMQMailQueueTest.java
@@ -18,9 +18,8 @@
****************************************************************/
package org.apache.james.queue.activemq;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.james.metrics.api.GaugeRegistry;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.queue.api.DelayedManageableMailQueueContract;
@@ -33,6 +32,7 @@ import org.apache.james.queue.api.ManageableMailQueue;
import org.apache.james.queue.api.PriorityManageableMailQueueContract;
import org.apache.james.queue.api.RawMailQueueItemDecoratorFactory;
import org.apache.james.queue.jms.BrokerExtension;
+import org.apache.james.queue.jms.JMSCacheableMailQueue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -45,22 +45,17 @@ import org.junit.jupiter.api.extension.ExtendWith;
public class ActiveMQMailQueueTest implements DelayedManageableMailQueueContract, DelayedPriorityMailQueueContract, PriorityManageableMailQueueContract,
MailQueueMetricContract {
- static final boolean USE_BLOB = true;
-
- ActiveMQCacheableMailQueue mailQueue;
+ JMSCacheableMailQueue mailQueue;
@BeforeEach
- public void setUp(BrokerService broker, MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
- connectionFactory.setTrustAllPackages(false);
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- connectionFactory.setPrefetchPolicy(prefetchPolicy);
+ public void setUp(EmbeddedActiveMQ broker, MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) {
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://0");
+ connectionFactory.setConsumerWindowSize(0);
RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
MetricFactory metricFactory = metricTestSystem.getMetricFactory();
GaugeRegistry gaugeRegistry = metricTestSystem.getSpyGaugeRegistry();
- MailQueueName queueName = BrokerExtension.generateRandomQueueName(broker);
- mailQueue = new ActiveMQCacheableMailQueue(connectionFactory, mailQueueItemDecoratorFactory, queueName, !USE_BLOB, metricFactory, gaugeRegistry);
+ MailQueueName queueName = BrokerExtension.generateRandomQueueName();
+ mailQueue = new JMSCacheableMailQueue(connectionFactory, mailQueueItemDecoratorFactory, queueName, metricFactory, gaugeRegistry);
}
@AfterEach
diff --git a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorTest.java b/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorTest.java
deleted file mode 100644
index bbced39ca8..0000000000
--- a/server/queue/queue-activemq/src/test/java/org/apache/james/queue/activemq/metric/ActiveMQMetricCollectorTest.java
+++ /dev/null
@@ -1,144 +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.queue.activemq.metric;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-import java.time.Duration;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import jakarta.jms.JMSException;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.james.metrics.api.Gauge;
-import org.apache.james.metrics.api.GaugeRegistry;
-import org.apache.james.metrics.api.NoopGaugeRegistry;
-import org.apache.james.metrics.tests.RecordingMetricFactory;
-import org.apache.james.queue.activemq.ActiveMQConfiguration;
-import org.apache.james.queue.api.MailQueueName;
-import org.apache.james.queue.jms.BrokerExtension;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-@ExtendWith(BrokerExtension.class)
-@Tag(BrokerExtension.STATISTICS)
-class ActiveMQMetricCollectorTest {
-
- private static ActiveMQConnectionFactory connectionFactory;
- private static final ActiveMQConfiguration EMPTY_CONFIGURATION = ActiveMQConfiguration.getDefault();
-
- @BeforeAll
- static void setup(BrokerService broker) {
- connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- connectionFactory.setPrefetchPolicy(prefetchPolicy);
- }
-
- @Test
- void shouldFailToFetchAndUpdateStatisticsForUnknownQueue() {
- SimpleGaugeRegistry gaugeRegistry = new SimpleGaugeRegistry();
- ActiveMQMetricCollectorImpl testee = new ActiveMQMetricCollectorImpl(EMPTY_CONFIGURATION, connectionFactory, new RecordingMetricFactory(), gaugeRegistry);
- ActiveMQMetrics queueStatistics = ActiveMQMetrics.forQueue("UNKNOWN", gaugeRegistry);
-
- assertThatThrownBy(() -> testee.fetchAndUpdate(queueStatistics))
- .isInstanceOf(JMSException.class);
-
- assertThat(gaugeRegistry.getGauge("ActiveMQ.Statistics.Destination.UNKNOWN")).isNull();
- }
-
- @Test
- void shouldFetchAndUpdateBrokerStatistics() throws Exception {
- SimpleGaugeRegistry gaugeRegistry = new SimpleGaugeRegistry();
- ActiveMQMetricCollectorImpl testee = new ActiveMQMetricCollectorImpl(EMPTY_CONFIGURATION, connectionFactory, new RecordingMetricFactory(), gaugeRegistry);
- ActiveMQMetrics brokerStatistics = ActiveMQMetrics.forBroker(gaugeRegistry);
-
- long notBefore = System.currentTimeMillis();
- testee.fetchAndUpdate(brokerStatistics);
- Number n = gaugeRegistry.getGauge("ActiveMQ.Statistics.Broker.lastUpdate");
- assertThat(n).isInstanceOf(Long.class);
- assertThat((Long) n).isGreaterThanOrEqualTo(notBefore);
- }
-
- @Test
- void shouldFetchAndUpdateBrokerStatisticsInGaugeRegistry() throws Exception {
- SimpleGaugeRegistry gaugeRegistry = new SimpleGaugeRegistry();
- ActiveMQMetricCollectorImpl testee = new ActiveMQMetricCollectorImpl(EMPTY_CONFIGURATION, connectionFactory, new RecordingMetricFactory(), gaugeRegistry);
- ActiveMQMetrics brokerStatistics = ActiveMQMetrics.forBroker(gaugeRegistry);
-
- testee.fetchAndUpdate(brokerStatistics);
-
- Number n = gaugeRegistry.getGauge("ActiveMQ.Statistics.Broker.storeLimit");
- assertThat(n).isInstanceOf(Long.class);
- assertThat((Long) n).isGreaterThan(0);
- }
-
- @Test
- void hasExecutionTimeMetrics() {
- RecordingMetricFactory metricFactory = new RecordingMetricFactory();
- NoopGaugeRegistry gaugeRegistry = new NoopGaugeRegistry();
- ActiveMQMetricCollector testee = new ActiveMQMetricCollectorImpl(EMPTY_CONFIGURATION, connectionFactory, metricFactory, gaugeRegistry);
- testee.start();
- testee.collectBrokerStatistics();
- testee.collectQueueStatistics(MailQueueName.of("UNKNOWN"));
-
- Duration startDelay = EMPTY_CONFIGURATION.getMetricConfiguration().getStartDelay();
- Integer executionTimeCount = Flux.interval(startDelay, Duration.ofSeconds(1))
- .take(3,true)
- .flatMap(n -> Mono.fromCallable(() -> metricFactory.executionTimesForPrefixName("ActiveMQ.").size()))
- .blockLast();
- assertThat(executionTimeCount).isNotNull().isNotZero();
-
- testee.stop();
- }
-
- private class SimpleGaugeRegistry implements GaugeRegistry {
- private final Map<String, Gauge<?>> gauges = new ConcurrentHashMap<>();
-
- @Override
- public <T> GaugeRegistry register(String name, Gauge<T> gauge) {
- gauges.put(name, gauge);
- return this;
- }
-
- @Override
- public <T> SettableGauge<T> settableGauge(String name) {
- return t -> gauges.put(name, () -> t);
- }
-
- public Number getGauge(String name) {
- Gauge<?> g = gauges.get(name);
- if (g == null) {
- return null;
- }
- return (Number) g.get();
- }
- }
-}
-
diff --git a/server/queue/queue-jms/pom.xml b/server/queue/queue-jms/pom.xml
index 4e9730e2bc..7e52ab69da 100644
--- a/server/queue/queue-jms/pom.xml
+++ b/server/queue/queue-jms/pom.xml
@@ -97,13 +97,13 @@
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-broker</artifactId>
- <scope>test</scope>
+ <groupId>org.apache.artemis</groupId>
+ <artifactId>artemis-jakarta-client</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jakarta-client</artifactId>
+ <groupId>org.apache.artemis</groupId>
+ <artifactId>artemis-jakarta-server</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
index cba434d514..ccbd928091 100644
--- a/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
+++ b/server/queue/queue-jms/src/main/java/org/apache/james/queue/jms/JMSCacheableMailQueue.java
@@ -157,6 +157,54 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
private static final Logger LOGGER = LoggerFactory.getLogger(JMSCacheableMailQueue.class);
public static final String FORCE_DELIVERY = "FORCE_DELIVERY";
+ private static final String JAMES_MAIL_ATTR_PROP_PREFIX = "JAMES_ATTR_";
+
+ protected static String encodeAttributePropertyName(String attributeName) {
+ StringBuilder sb = new StringBuilder(JAMES_MAIL_ATTR_PROP_PREFIX);
+ for (int i = 0; i < attributeName.length(); i++) {
+ char c = attributeName.charAt(i);
+ if (Character.isJavaIdentifierPart(c)) {
+ sb.append(c);
+ } else {
+ sb.append(String.format("_%04x_", (int) c));
+ }
+ }
+ return sb.toString();
+ }
+
+ protected static String encodePerRecipientHeaderPropertyName(String recipientAddress) {
+ StringBuilder sb = new StringBuilder(JAMES_MAIL_PER_RECIPIENT_HEADERS).append('_');
+ for (int i = 0; i < recipientAddress.length(); i++) {
+ char c = recipientAddress.charAt(i);
+ if (Character.isJavaIdentifierPart(c)) {
+ sb.append(c);
+ } else {
+ sb.append(String.format("_%04x_", (int) c));
+ }
+ }
+ return sb.toString();
+ }
+
+ protected static String decodePerRecipientHeaderPropertyName(String propertyName) {
+ String encoded = propertyName.substring((JAMES_MAIL_PER_RECIPIENT_HEADERS + "_").length());
+ StringBuilder sb = new StringBuilder();
+ int i = 0;
+ while (i < encoded.length()) {
+ if (encoded.charAt(i) == '_' && i + 5 < encoded.length() && encoded.charAt(i + 5) == '_') {
+ try {
+ int charCode = Integer.parseInt(encoded.substring(i + 1, i + 5), 16);
+ sb.append((char) charCode);
+ i += 6;
+ continue;
+ } catch (NumberFormatException e) {
+ // Not encoded hex, fall through
+ }
+ }
+ sb.append(encoded.charAt(i));
+ i++;
+ }
+ return sb.toString();
+ }
protected final MailQueueName queueName;
protected final Connection connection;
@@ -284,8 +332,9 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
try {
- int msgPrio = AttributeUtils.getValueAndCastFromMail(mail, MAIL_PRIORITY, Integer.class)
+ int rawPriority = AttributeUtils.getValueAndCastFromMail(mail, MAIL_PRIORITY, Integer.class)
.orElse(NORMAL_PRIORITY);
+ int msgPrio = Math.max(0, Math.min(9, rawPriority));
Map<String, Object> props = getJMSProperties(mail, nextDeliveryTimestamp);
produceMail(props, msgPrio, mail);
@@ -362,7 +411,7 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
mail.getPerRecipientSpecificHeaders().getHeadersByRecipient()
.asMap()
- .forEach((recipient, headers) -> props.put(JAMES_MAIL_PER_RECIPIENT_HEADERS + "-" + recipient.asString(),
+ .forEach((recipient, headers) -> props.put(encodePerRecipientHeaderPropertyName(recipient.asString()),
Joiner.on('\n')
.join(headers.stream()
.map(PerRecipientHeaders.Header::asString)
@@ -377,7 +426,7 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
String sender = mail.getMaybeSender().asString("");
props.putAll(mail.attributes()
- .flatMap(attribute -> attribute.getValue().toJson().map(JsonNode::toString).map(s -> Pair.of(attribute.getName().asString(), s)).stream())
+ .flatMap(attribute -> attribute.getValue().toJson().map(JsonNode::toString).map(s -> Pair.of(encodeAttributePropertyName(attribute.getName().asString()), s)).stream())
.collect(ImmutableMap.toImmutableMap(Pair::getKey, Pair::getValue)));
ImmutableList<String> attributeNames = mail.attributeNames()
@@ -437,10 +486,16 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
PerRecipientHeaders perRecipientHeaders = new PerRecipientHeaders();
ImmutableList.copyOf(properties.asIterator())
.stream()
- .filter(property -> property.startsWith(JAMES_MAIL_PER_RECIPIENT_HEADERS + "-"))
+ .filter(property -> property.startsWith(JAMES_MAIL_PER_RECIPIENT_HEADERS + "_") || property.startsWith(JAMES_MAIL_PER_RECIPIENT_HEADERS + "-"))
.flatMap(property -> {
try {
- MailAddress address = new MailAddress(property.substring(JAMES_MAIL_PER_RECIPIENT_HEADERS.length() + 1));
+ String recipientStr;
+ if (property.startsWith(JAMES_MAIL_PER_RECIPIENT_HEADERS + "_")) {
+ recipientStr = decodePerRecipientHeaderPropertyName(property);
+ } else {
+ recipientStr = property.substring(JAMES_MAIL_PER_RECIPIENT_HEADERS.length() + 1);
+ }
+ MailAddress address = new MailAddress(recipientStr);
String headers = message.getStringProperty(property);
return Splitter.on('\n').splitToStream(headers)
.map(PerRecipientHeaders.Header::fromString)
@@ -485,8 +540,22 @@ public class JMSCacheableMailQueue implements ManageableMailQueue, JMSSupport, M
private Stream<Attribute> mailAttribute(Message message, String name) {
// Now cast the property back to Serializable and set it as attribute.
- // See JAMES-1241
- Object attrValue = Throwing.function(message::getObjectProperty).apply(name);
+ // See JAMES-1241. Property name is encoded to ensure it is a valid JMS identifier.
+ String encodedPropName = encodeAttributePropertyName(name);
+ Object attrValue;
+ try {
+ attrValue = message.getObjectProperty(encodedPropName);
+ if (attrValue == null) {
+ attrValue = message.getObjectProperty(name);
+ }
+ } catch (Exception e) {
+ LOGGER.warn("Error reading mail attribute {} from JMS message. Skipping attribute.", name, e);
+ return Stream.empty();
+ }
+
+ if (attrValue == null) {
+ return Stream.empty();
+ }
if (attrValue instanceof String) {
try {
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/BrokerExtension.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/BrokerExtension.java
index 237554681e..94700bd436 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/BrokerExtension.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/BrokerExtension.java
@@ -19,11 +19,13 @@
package org.apache.james.queue.jms;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.region.policy.PolicyEntry;
-import org.apache.activemq.broker.region.policy.PolicyMap;
-import org.apache.activemq.plugin.StatisticsBrokerPlugin;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
import org.apache.commons.text.RandomStringGenerator;
import org.apache.james.queue.api.MailQueueName;
import org.junit.jupiter.api.extension.AfterAllCallback;
@@ -33,40 +35,46 @@ import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver;
-import com.google.common.collect.ImmutableList;
-
-public class BrokerExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback {
+/**
+ * JUnit 5 extension providing an embedded Artemis broker for JMS queue tests.
+ * Replaces the legacy ActiveMQ BrokerService-based extension.
+ */
+public class BrokerExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback {
public static final String STATISTICS = "Statistics";
- public static MailQueueName generateRandomQueueName(BrokerService broker) {
+ /** Unique broker ID counter to avoid conflicts when multiple tests run. */
+ private static final AtomicInteger BROKER_COUNTER = new AtomicInteger(0);
+
+ /**
+ * Generate a random queue name for the embedded broker.
+ * Priority support is handled by Artemis natively; no extra configuration needed.
+ */
+ public static MailQueueName generateRandomQueueName() {
String queueName = new RandomStringGenerator.Builder().withinRange('a', 'z').build().generate(10);
- BrokerExtension.enablePrioritySupport(broker, queueName);
return MailQueueName.of(queueName);
}
- private static void enablePrioritySupport(BrokerService aBroker, String queueName) {
- PolicyMap pMap = new PolicyMap();
- PolicyEntry entry = new PolicyEntry();
- entry.setPrioritizedMessages(true);
- entry.setQueue(queueName);
- pMap.setPolicyEntries(ImmutableList.of(entry));
- aBroker.setDestinationPolicy(pMap);
- }
+ private final EmbeddedActiveMQ broker;
+ private final int brokerId;
- private final BrokerService broker;
-
- public BrokerExtension() throws Exception {
- broker = new BrokerService();
- broker.setPersistent(false);
- broker.setUseJmx(false);
+ public BrokerExtension() throws Exception {
+ brokerId = BROKER_COUNTER.incrementAndGet();
+ Configuration config = new ConfigurationImpl()
+ .setSecurityEnabled(false)
+ .setJMXManagementEnabled(false)
+ .setPersistenceEnabled(false)
+ .addAcceptorConfiguration(new TransportConfiguration(
+ InVMAcceptorFactory.class.getName(),
+ java.util.Collections.singletonMap("server-id", String.valueOf(brokerId))
+ ))
+ .setName("test-broker-" + brokerId);
+ broker = new EmbeddedActiveMQ();
+ broker.setConfiguration(config);
}
@Override
public void beforeAll(ExtensionContext context) throws Exception {
- if (context.getTags().contains(STATISTICS)) {
- enableStatistics(broker);
- }
broker.start();
}
@@ -75,14 +83,9 @@ public class BrokerExtension implements ParameterResolver, BeforeAllCallback, A
broker.stop();
}
- private void enableStatistics(BrokerService broker) {
- broker.setPlugins(new BrokerPlugin[]{new StatisticsBrokerPlugin()});
- broker.setEnableStatistics(true);
- }
-
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException {
- return (parameterContext.getParameter().getType() == BrokerService.class);
+ return parameterContext.getParameter().getType() == EmbeddedActiveMQ.class;
}
@Override
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueFactoryTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueFactoryTest.java
index cca41fd939..6f78c28f8c 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueFactoryTest.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueFactoryTest.java
@@ -21,8 +21,8 @@ package org.apache.james.queue.jms;
import jakarta.jms.ConnectionFactory;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.james.metrics.api.GaugeRegistry;
import org.apache.james.metrics.api.NoopGaugeRegistry;
import org.apache.james.metrics.tests.RecordingMetricFactory;
@@ -42,8 +42,8 @@ public class JMSCacheableMailQueueFactoryTest implements MailQueueFactoryContrac
private JMSMailQueueFactory mailQueueFactory;
@BeforeEach
- void setUp(BrokerService broker) {
- ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
+ void setUp(EmbeddedActiveMQ broker) {
+ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://0");
RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
RecordingMetricFactory metricFactory = new RecordingMetricFactory();
GaugeRegistry gaugeRegistry = new NoopGaugeRegistry();
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueuePropertyNameTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueuePropertyNameTest.java
new file mode 100644
index 0000000000..0ed7292077
--- /dev/null
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueuePropertyNameTest.java
@@ -0,0 +1,200 @@
+/****************************************************************
+ * 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.jms;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+class JMSCacheableMailQueuePropertyNameTest {
+
+ private static final String ATTRIBUTE_PREFIX = "JAMES_ATTR_";
+ private static final String PER_RECIPIENT_PREFIX = JMSCacheableMailQueue.JAMES_MAIL_PER_RECIPIENT_HEADERS + "_";
+
+ @Nested
+ class AttributePropertyNameEncoding {
+
+ @Test
+ void shouldPrependAttributePrefix() {
+ assertThat(JMSCacheableMailQueue.encodeAttributePropertyName("simple"))
+ .isEqualTo(ATTRIBUTE_PREFIX + "simple");
+ }
+
+ @Test
+ void shouldPreserveValidJavaIdentifierParts() {
+ String input = "simple_attribute_123$name";
+ assertThat(JMSCacheableMailQueue.encodeAttributePropertyName(input))
+ .isEqualTo(ATTRIBUTE_PREFIX + input);
+ }
+
+ @Test
+ void shouldEncodeDotsInAttributeNames() {
+ // Dots are common in hierarchical James attribute names e.g. org.apache.james.attribute
+ String encoded = JMSCacheableMailQueue.encodeAttributePropertyName("org.apache.james");
+ assertThat(encoded)
+ .doesNotContain(".")
+ .isEqualTo(ATTRIBUTE_PREFIX + "org_002e_apache_002e_james");
+ }
+
+ @Test
+ void shouldEncodeHyphensAndSpacesInAttributeNames() {
+ String encoded = JMSCacheableMailQueue.encodeAttributePropertyName("my-attr name");
+ assertThat(encoded)
+ .doesNotContain("-")
+ .doesNotContain(" ")
+ .isEqualTo(ATTRIBUTE_PREFIX + "my_002d_attr_0020_name");
+ }
+
+ @Test
+ void shouldEncodeNonAsciiCharacters() {
+ String encoded = JMSCacheableMailQueue.encodeAttributePropertyName("тест");
+ // Cyrillic characters are valid Java identifier parts according to Character.isJavaIdentifierPart
+ // Verify behavior conforms to Character.isJavaIdentifierPart
+ StringBuilder expected = new StringBuilder(ATTRIBUTE_PREFIX);
+ for (char c : "тест".toCharArray()) {
+ if (Character.isJavaIdentifierPart(c)) {
+ expected.append(c);
+ } else {
+ expected.append(String.format("_%04x_", (int) c));
+ }
+ }
+ assertThat(encoded).isEqualTo(expected.toString());
+ }
+
+ @Test
+ void shouldHandleEmptyAttributeName() {
+ assertThat(JMSCacheableMailQueue.encodeAttributePropertyName(""))
+ .isEqualTo(ATTRIBUTE_PREFIX);
+ }
+ }
+
+ @Nested
+ class PerRecipientHeaderPropertyNameEncoding {
+
+ @Test
+ void shouldPrependPerRecipientHeaderPrefix() {
+ assertThat(JMSCacheableMailQueue.encodePerRecipientHeaderPropertyName("user"))
+ .isEqualTo(PER_RECIPIENT_PREFIX + "user");
+ }
+
+ @Test
+ void shouldEncodeEmailSpecialCharacters() {
+ // Recipient addresses contain '@' and '.' and optionally '+', '-'
+ String email = "user.name+tag@example-domain.com";
+ String encoded = JMSCacheableMailQueue.encodePerRecipientHeaderPropertyName(email);
+
+ assertThat(encoded)
+ .startsWith(PER_RECIPIENT_PREFIX)
+ .doesNotContain("@")
+ .doesNotContain(".")
+ .doesNotContain("+")
+ .doesNotContain("-");
+
+ assertThat(encoded)
+ .isEqualTo(PER_RECIPIENT_PREFIX + "user_002e_name_002b_tag_0040_example_002d_domain_002e_com");
+ }
+ }
+
+ @Nested
+ class PerRecipientHeaderPropertyNameDecoding {
+
+ @Test
+ void shouldDecodeSimplePropertyName() {
+ String propertyName = PER_RECIPIENT_PREFIX + "user";
+ assertThat(JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(propertyName))
+ .isEqualTo("user");
+ }
+
+ @Test
+ void shouldDecodeEncodedHexSequences() {
+ String propertyName = PER_RECIPIENT_PREFIX + "user_0040_domain_002e_com";
+ assertThat(JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(propertyName))
+ .isEqualTo("user@domain.com");
+ }
+
+ @Test
+ void shouldTolerateUnderscoresWithoutValidHex() {
+ // An underscore not followed by a 4-hex pattern should be preserved as-is
+ String propertyName = PER_RECIPIENT_PREFIX + "user_name_test";
+ assertThat(JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(propertyName))
+ .isEqualTo("user_name_test");
+ }
+
+ @Test
+ void shouldTolerateMalformedHexWithinUnderscores() {
+ // _xxxx_ where xxxx is not valid hexadecimal should fall through and not throw
+ String propertyName = PER_RECIPIENT_PREFIX + "user_zzzz_test";
+ assertThat(JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(propertyName))
+ .isEqualTo("user_zzzz_test");
+ }
+
+ @Test
+ void shouldTolerateTrailingUnderscoreAtEnd() {
+ String propertyName = PER_RECIPIENT_PREFIX + "user_";
+ assertThat(JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(propertyName))
+ .isEqualTo("user_");
+ }
+
+ @Test
+ void shouldTolerateShortUnderscorePattern() {
+ String propertyName = PER_RECIPIENT_PREFIX + "user_12_test";
+ assertThat(JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(propertyName))
+ .isEqualTo("user_12_test");
+ }
+ }
+
+ @Nested
+ class RoundTripEncodingDecoding {
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ "user@domain.tld",
+ "first.last@sub.domain.org",
+ "user+tag@domain.com",
+ "a_b-c.d+e@domain-with-dash.com",
+ "123456@numbers.com",
+ "user!def#ghi$jkl%mno&pqr'stu*vwx/yz=123?456^789_`{|}~@special.com",
+ "admin@localhost"
+ })
+ void shouldRoundTripRecipientAddressesConsistently(String recipientAddress) {
+ String encodedProperty = JMSCacheableMailQueue.encodePerRecipientHeaderPropertyName(recipientAddress);
+ String decodedRecipient = JMSCacheableMailQueue.decodePerRecipientHeaderPropertyName(encodedProperty);
+
+ assertThat(decodedRecipient).isEqualTo(recipientAddress);
+ }
+
+ @Test
+ void encodedPropertyNameShouldBeValidJMSIdentifierPart() {
+ String email = "complex.name+tag@sub-domain.example.com";
+ String encodedProperty = JMSCacheableMailQueue.encodePerRecipientHeaderPropertyName(email);
+
+ // In JMS, property names must follow Java identifier conventions
+ assertThat(Character.isJavaIdentifierStart(encodedProperty.charAt(0))).isTrue();
+ for (int i = 1; i < encodedProperty.length(); i++) {
+ assertThat(Character.isJavaIdentifierPart(encodedProperty.charAt(i)))
+ .as("Character at index %d ('%c') must be a valid Java identifier part", i, encodedProperty.charAt(i))
+ .isTrue();
+ }
+ }
+ }
+}
diff --git a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java
index 56e72a6f85..b8cf764013 100644
--- a/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java
+++ b/server/queue/queue-jms/src/test/java/org/apache/james/queue/jms/JMSCacheableMailQueueTest.java
@@ -19,9 +19,8 @@
package org.apache.james.queue.jms;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.ActiveMQPrefetchPolicy;
-import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.james.metrics.api.GaugeRegistry;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.queue.api.DelayedManageableMailQueueContract;
@@ -46,15 +45,14 @@ public class JMSCacheableMailQueueTest implements DelayedManageableMailQueueCont
private JMSCacheableMailQueue mailQueue;
@BeforeEach
- void setUp(BrokerService broker, MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) {
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?create=false");
- ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy();
- prefetchPolicy.setQueuePrefetch(0);
- connectionFactory.setPrefetchPolicy(prefetchPolicy);
+ void setUp(EmbeddedActiveMQ broker, MailQueueMetricExtension.MailQueueMetricTestSystem metricTestSystem) {
+ // Use InVM transport - broker ID matches BrokerExtension instance counter
+ ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://0");
+ connectionFactory.setConsumerWindowSize(0);
RawMailQueueItemDecoratorFactory mailQueueItemDecoratorFactory = new RawMailQueueItemDecoratorFactory();
MetricFactory metricFactory = metricTestSystem.getMetricFactory();
GaugeRegistry gaugeRegistry = metricTestSystem.getSpyGaugeRegistry();
- MailQueueName queueName = BrokerExtension.generateRandomQueueName(broker);
+ MailQueueName queueName = BrokerExtension.generateRandomQueueName();
mailQueue = new JMSCacheableMailQueue(connectionFactory, mailQueueItemDecoratorFactory, queueName, metricFactory, gaugeRegistry);
}
@@ -68,7 +66,6 @@ public class JMSCacheableMailQueueTest implements DelayedManageableMailQueueCont
return mailQueue;
}
- @Test
@Override
public ManageableMailQueue getManageableMailQueue() {
return mailQueue;
diff --git a/src/adr/0076-artemis-mailqueue-migration.md b/src/adr/0076-artemis-mailqueue-migration.md
new file mode 100644
index 0000000000..b091eba17b
--- /dev/null
+++ b/src/adr/0076-artemis-mailqueue-migration.md
@@ -0,0 +1,67 @@
+# 76. Migration from ActiveMQ Classic to ActiveMQ Artemis for Embedded Mail Queue
+
+Date: 2026-09-22
+
+## Status
+
+Accepted & implemented.
+
+## Context
+
+Apache James provides a mail spool queue mechanism implemented via JMS (`server/queue/queue-activemq`).
+Previously, the embedded broker relied on Apache ActiveMQ "Classic" (5.x/6.x) with KahaDB persistence adapter and ActiveMQ-specific `BlobMessage` / `FileSystemBlobTransferPolicy`.
+
+Under real-world and high workloads, ActiveMQ Classic suffered from severe design and performance limitations:
+
+1. **Throughput and Latency Bottleneck:**
+ - Out-of-the-box ActiveMQ Classic experiences high latency (~100 ms) and limited throughput (~25-400 msgs/s depending on storage sync and KahaDB locking).
+ - Java profiling revealed that up to 95% of total request processing time inside James was spent waiting on ActiveMQ / KahaDB queue commits.
+
+2. **Head-of-Line Blocking with Delayed Mails (JAMES-4192):**
+ - In James Remote Delivery, retries are scheduled with delays (e.g., 30–60 minutes) upon encountering temporary exceptions (such as greylisting / SMTP 421).
+ - Dequeueing uses JMS message selectors (`JAMES_NEXT_DELIVERY <= currentTimeMillis() OR FORCE_DELIVERY = true`).
+ - In ActiveMQ Classic, messages are read into memory in batches governed by `maxPageSize` (default: 200). If ≥200 delayed messages reside at the head of the queue, the selector rejects them, but ActiveMQ Classic **stops evaluating further pages**.
+ - As a result, the entire outgoing delivery stalls for the duration of the delay window, completely starving non-delayed, ready-to-deliver messages.
+
+3. **Proprietary Blob Messages:**
+ - Out-of-band blob messages (`BlobMessage`, `FileSystemBlobTransferPolicy`) in ActiveMQ Classic are non-portable, lack clean garbage-collection guarantees, and complicate embedded deployments.
+
+Apache ActiveMQ Artemis is the modern, next-generation message broker from the ActiveMQ project, designed from the ground up for asynchronous non-blocking I/O, low latency, native journal persistence, and Jakarta Messaging 3.x compliance.
+
+## Decision
+
+Migrate the embedded message queue broker in Apache James from ActiveMQ Classic to **Apache ActiveMQ Artemis**:
+
+1. **Embedded Broker Architecture (`EmbeddedActiveMQ.java`):**
+ - Use `org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ` running in-VM (`vm://0`).
+ - Use Artemis native high-performance journal storage for bindings, journal, paging, and large messages (`setPersistenceEnabled(true)`).
+ - Configure optimal embedded JMS client connection factory with `setConsumerWindowSize(0)` and `setBlockOnAcknowledge(true)`.
+
+2. **Delayed Delivery Handling (JAMES-4192):**
+ - ActiveMQ Artemis natively supports the Jakarta Messaging delivery delay specification via an internal dedicated scheduler (`ScheduledDeliveryHandler`).
+ - Delayed messages remain tracked on the destination (accessible via `scheduledCount`), preventing inconsistencies between queue reporting and delivery state.
+ - Note: While Artemis improves scheduler handling in memory, head-of-line blocking under heavy paging with message selectors ([JAMES-4192](https://issues.apache.org/jira/browse/JAMES-4192)) still requires dedicated architectural work and is deferred to a follow-up issue.
+
+3. **JMS Mail Queue Implementation:**
+ - Standardize on standard Jakarta JMS `ObjectMessage` / `BytesMessage` instead of ActiveMQ proprietary `BlobMessage`.
+ - Large messages are handled natively and transparently by Artemis file streaming (`setLargeMessagesDirectory`) without requiring custom blob transfer protocols.
+ - Enforce strict compliance with JMS identifier rules for message properties (`AMQ139012`), escaping dots and hyphens into hexadecimal sequences.
+
+4. **Metrics & Health Check:**
+ - ActiveMQ Classic's `StatisticsBrokerPlugin` (request-reply destination statistics via advisory temporary queues) was proprietary to Classic and is omitted in Artemis. The legacy broker-stats polling collector is substituted by a safe no-op implementation (`ActiveMQMetricCollectorNoop`).
+ - James application-level queue metrics (`enqueuedMailsMetric`, `dequeuedMailsMetric`, and `queueSizeGauge`) remain fully gathered inside James via `JMSCacheableMailQueue` through standard `MetricFactory` and `GaugeRegistry`.
+ - Broker-level metrics in Artemis are natively exposed via Micrometer / Prometheus or JMX.
+ - Maintain `ActiveMQHealthCheck` verifying connectivity and session creation.
+
+## Consequences
+
+- **Performance:** Substantially higher spooling throughput (scaling from ~350-400 msgs/s on ActiveMQ Classic to 1,700–2,000+ msgs/s with Artemis) with minimal spool latency.
+- **Reliability:** Improved handling of scheduled delivery and modern broker architecture. Resolving selector evaluation on paged-out queues (JAMES-4192) will be addressed in a follow-up.
+- **Large Messages:** Robust and standardized large payload streaming without custom blob store lifecycles.
+- **Migration & Upgrade:** Artemis uses an independent, high-performance journal format and cannot directly parse legacy KahaDB journals. Operators must drain/flush existing mail queues before upgrading James versions.
+
+## References
+
+- [JAMES-4192: ActiveMQ MailQueue cannot dequeue when lots of delayed mails](https://issues.apache.org/jira/browse/JAMES-4192)
+- [Apache James PR #3194](https://github.com/apache/james-project/pull/3194)
+- [Artemis Scheduled Message Architecture](https://activemq.apache.org/components/artemis/documentation/latest/scheduled-messages.html)
diff --git a/upgrade-instructions.md b/upgrade-instructions.md
index 4e84aba178..6919c38238 100644
--- a/upgrade-instructions.md
+++ b/upgrade-instructions.md
@@ -25,6 +25,23 @@ Change list:
- [JAMES-4225 Blob ids default to 128 bits of entropy](#james-4225-blob-ids-default-to-128-bits-of-entropy)
- [Dropping unneeded Cassandra schema columns](#dropping-unneeded-cassandra-schema-columns)
- [Cassandra schema version 16: mandatory message denormalization migration](#cassandra-schema-version-16-mandatory-message-denormalization-migration)
+ - [Migration of embedded mail queue broker from ActiveMQ Classic to ActiveMQ Artemis](#migration-of-embedded-mail-queue-broker-from-activemq-classic-to-activemq-artemis)
+
+### Migration of embedded mail queue broker from ActiveMQ Classic to ActiveMQ Artemis
+
+Date: 22/09/2026
+
+Concerned products: memory/postgres/jpa James servers relying on embedded ActiveMQ (`queue-activemq`).
+
+The embedded message broker has been migrated from Apache ActiveMQ Classic (5.x/6.x) with KahaDB to Apache ActiveMQ Artemis (2.x) with native journal storage.
+
+**Important for Operators:**
+ActiveMQ Artemis uses a different on-disk persistence layout and journal format than KahaDB. As a result, mail queues stored in ActiveMQ Classic will not be automatically read by Artemis.
+Operators upgrading from an earlier version must:
+1. Isolate the mail server (or temporarily reject new incoming SMTP traffic).
+2. Allow existing mail queues to drain / flush completely before upgrading James.
+3. Once the queues are empty, upgrade James to the new version.
+4. If you have legacy KahaDB data directories (e.g. `var/store/activemq`), they can be safely archived or removed after successful verification.
### Dropping unneeded Cassandra schema columns
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org