diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java index 1553ccb9e4..24dc15c5b7 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQScheduledComponent.java @@ -188,6 +188,13 @@ public abstract class ActiveMQScheduledComponent implements ActiveMQComponent, R return this; } + public synchronized ActiveMQScheduledComponent setPeriod(long period, TimeUnit unit) { + this.period = period; + this.timeUnit = unit; + restartIfNeeded(); + return this; + } + public long getInitialDelay() { return initialDelay; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index ab47aa7cf8..c1b20e3cc5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -494,6 +494,8 @@ public class ActiveMQServerImpl implements ActiveMQServer { configuration.parseSystemProperties(); + initializeExecutorServices(); + startDate = new Date(); state = SERVER_STATE.STARTING; @@ -1982,9 +1984,6 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (state == SERVER_STATE.STOPPED) return false; - // Create the pools - we have two pools - one for non scheduled - and another for scheduled - initializeExecutorServices(); - if (configuration.getJournalType() == JournalType.ASYNCIO) { if (!AIOSequentialFileFactory.isSupported()) { ActiveMQServerLogger.LOGGER.switchingNIO(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ActiveMQScheduledLeaseLock.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ActiveMQScheduledLeaseLock.java index 30db62993d..e870ea90ec 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ActiveMQScheduledLeaseLock.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ActiveMQScheduledLeaseLock.java @@ -17,16 +17,16 @@ package org.apache.activemq.artemis.core.server.impl.jdbc; +import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.core.io.IOCriticalErrorListener; import org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent; -import org.apache.activemq.artemis.utils.actors.ArtemisExecutor; import org.jboss.logging.Logger; /** - * Default implementation of a {@link ScheduledLeaseLock}: see {@link ScheduledLeaseLock#of(ScheduledExecutorService, ArtemisExecutor, String, LeaseLock, long, IOCriticalErrorListener)}. + * Default implementation of a {@link ScheduledLeaseLock}: see {@link ScheduledLeaseLock#of(ScheduledExecutorService, Executor, String, LeaseLock, long, IOCriticalErrorListener)}. */ final class ActiveMQScheduledLeaseLock extends ActiveMQScheduledComponent implements ScheduledLeaseLock { @@ -39,7 +39,7 @@ final class ActiveMQScheduledLeaseLock extends ActiveMQScheduledComponent implem private final IOCriticalErrorListener ioCriticalErrorListener; ActiveMQScheduledLeaseLock(ScheduledExecutorService scheduledExecutorService, - ArtemisExecutor executor, + Executor executor, String lockName, LeaseLock lock, long renewPeriodMillis, diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ScheduledLeaseLock.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ScheduledLeaseLock.java index 43751f8671..4e1f480fbc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ScheduledLeaseLock.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/ScheduledLeaseLock.java @@ -17,11 +17,11 @@ package org.apache.activemq.artemis.core.server.impl.jdbc; +import java.util.concurrent.Executor; import java.util.concurrent.ScheduledExecutorService; import org.apache.activemq.artemis.core.io.IOCriticalErrorListener; import org.apache.activemq.artemis.core.server.ActiveMQComponent; -import org.apache.activemq.artemis.utils.actors.ArtemisExecutor; /** * {@link LeaseLock} holder that allows to schedule a {@link LeaseLock#renew} task with a fixed {@link #renewPeriodMillis()} delay. @@ -33,7 +33,7 @@ interface ScheduledLeaseLock extends ActiveMQComponent { long renewPeriodMillis(); static ScheduledLeaseLock of(ScheduledExecutorService scheduledExecutorService, - ArtemisExecutor executor, + Executor executor, String lockName, LeaseLock lock, long renewPeriodMillis,