Class ActiveMQScheduledComponent
- java.lang.Object
-
- org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent
-
- All Implemented Interfaces:
java.lang.Runnable,ActiveMQComponent
- Direct Known Subclasses:
NetworkHealthCheck
public abstract class ActiveMQScheduledComponent extends java.lang.Object implements ActiveMQComponent, java.lang.Runnable
This is for components with a scheduled at a fixed rate.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.Executorexecutorprotected java.util.concurrent.ScheduledExecutorServicescheduledExecutorService
-
Constructor Summary
Constructors Constructor Description ActiveMQScheduledComponent(long initialDelay, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, long initialDelay, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, java.util.concurrent.Executor executor, long initialDelay, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, java.util.concurrent.Executor executor, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandelay()A delay request can succeed only if: there is no other pending delay request there is no pending execution requestlonggetInitialDelay()longgetPeriod()protected ActiveMQThreadFactorygetThreadFactory()java.util.concurrent.TimeUnitgetTimeUnit()booleanisStarted()ActiveMQScheduledComponentsetInitialDelay(long initialDelay)ActiveMQScheduledComponentsetInitialDelayAndPeriod(long initialDelay, long period)Useful to change a running schedule and avoid multiple restarts.ActiveMQScheduledComponentsetInitialDelayAndPeriod(long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)Useful to change a running schedule and avoid multiple restarts.ActiveMQScheduledComponentsetPeriod(long period)ActiveMQScheduledComponentsetPeriod(long period, java.util.concurrent.TimeUnit unit)ActiveMQScheduledComponentsetTimeUnit(java.util.concurrent.TimeUnit timeUnit)voidstart()voidstop()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStop
-
-
-
-
Constructor Detail
-
ActiveMQScheduledComponent
public ActiveMQScheduledComponent(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, java.util.concurrent.Executor executor, long initialDelay, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.- Parameters:
scheduledExecutorService- theScheduledExecutorServicethat periodically triggerRunnable.run()on the configuredexecutorexecutor- theExecutorthat executeRunnable.run()when triggeredinitialDelay- the time to delay first executioncheckPeriod- the delay between the termination of one execution and the start of the nexttimeUnit- the time unit of theinitialDelayandcheckPeriodparametersonDemand- iftruethe task won't be scheduled onstart(),falseotherwise
-
ActiveMQScheduledComponent
public ActiveMQScheduledComponent(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, long initialDelay, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.- Parameters:
scheduledExecutorService- theScheduledExecutorServicethat periodically triggerRunnable.run()on the configuredexecutorinitialDelay- the time to delay first executioncheckPeriod- the delay between the termination of one execution and the start of the nexttimeUnit- the time unit of theinitialDelayandcheckPeriodparametersonDemand- iftruethe task won't be scheduled onstart(),falseotherwise
-
ActiveMQScheduledComponent
public ActiveMQScheduledComponent(java.util.concurrent.ScheduledExecutorService scheduledExecutorService, java.util.concurrent.Executor executor, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.The component created will have
initialDelaydefaulted tocheckPeriod.- Parameters:
scheduledExecutorService- theScheduledExecutorServicethat periodically triggerRunnable.run()on the configuredexecutorexecutor- theExecutorthat executeRunnable.run()when triggeredcheckPeriod- the delay between the termination of one execution and the start of the nexttimeUnit- the time unit of theinitialDelayandcheckPeriodparametersonDemand- iftruethe task won't be scheduled onstart(),falseotherwise
-
ActiveMQScheduledComponent
public ActiveMQScheduledComponent(long initialDelay, long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.This is useful for cases where we want our own scheduler executor: on
start()it will create a fresh new single-threadedScheduledExecutorServiceusinggetThreadFactory()andgetThisClassLoader(), while onstop()it will garbage it.- Parameters:
initialDelay- the time to delay first executioncheckPeriod- the delay between the termination of one execution and the start of the nexttimeUnit- the time unit of theinitialDelayandcheckPeriodparametersonDemand- iftruethe task won't be scheduled onstart(),falseotherwise
-
ActiveMQScheduledComponent
public ActiveMQScheduledComponent(long checkPeriod, java.util.concurrent.TimeUnit timeUnit, boolean onDemand)It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.This is useful for cases where we want our own scheduler executor. The component created will have
initialDelaydefaulted tocheckPeriod.- Parameters:
checkPeriod- the delay between the termination of one execution and the start of the nexttimeUnit- the time unit of theinitialDelayandcheckPeriodparametersonDemand- iftruethe task won't be scheduled onstart(),falseotherwise
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfaceActiveMQComponent
-
getThreadFactory
protected ActiveMQThreadFactory getThreadFactory()
-
delay
public boolean delay()
A delay request can succeed only if:- there is no other pending delay request
- there is no pending execution request
When a delay request succeed it schedule a new execution to happen in
getPeriod().
-
getPeriod
public long getPeriod()
-
setPeriod
public ActiveMQScheduledComponent setPeriod(long period)
-
setPeriod
public ActiveMQScheduledComponent setPeriod(long period, java.util.concurrent.TimeUnit unit)
-
getInitialDelay
public long getInitialDelay()
-
setInitialDelay
public ActiveMQScheduledComponent setInitialDelay(long initialDelay)
-
setInitialDelayAndPeriod
public ActiveMQScheduledComponent setInitialDelayAndPeriod(long initialDelay, long period)
Useful to change a running schedule and avoid multiple restarts.
-
setInitialDelayAndPeriod
public ActiveMQScheduledComponent setInitialDelayAndPeriod(long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)
Useful to change a running schedule and avoid multiple restarts.
-
getTimeUnit
public java.util.concurrent.TimeUnit getTimeUnit()
-
setTimeUnit
public ActiveMQScheduledComponent setTimeUnit(java.util.concurrent.TimeUnit timeUnit)
-
stop
public void stop()
- Specified by:
stopin interfaceActiveMQComponent
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceActiveMQComponent
-
-