Class ActiveMQScheduledComponent
java.lang.Object
org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent
- All Implemented Interfaces:
Runnable,ActiveMQComponent
- Direct Known Subclasses:
ClusterConnectionImpl.TopologyScanner,FileLockNodeManager.MonitorLock,FileStoreMonitor,NetworkHealthCheck,PageTimedWriter,ReloadManagerImpl,TargetMonitor
public abstract class ActiveMQScheduledComponent
extends Object
implements ActiveMQComponent, Runnable
This is for components with a scheduled at a fixed rate.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionActiveMQScheduledComponent(long initialDelay, long checkPeriod, TimeUnit timeUnit, boolean onDemand) It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(long checkPeriod, TimeUnit timeUnit, boolean onDemand) It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(ScheduledExecutorService scheduledExecutorService, long initialDelay, long checkPeriod, TimeUnit timeUnit, boolean onDemand) It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(ScheduledExecutorService scheduledExecutorService, Executor executor, long initialDelay, long checkPeriod, TimeUnit timeUnit, boolean onDemand) It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor.ActiveMQScheduledComponent(ScheduledExecutorService scheduledExecutorService, Executor executor, long checkPeriod, TimeUnit timeUnit, boolean onDemand) It creates a scheduled component that can triggerRunnable.run()with a fixedcheckPeriodon a configuredexecutor. -
Method Summary
Modifier and TypeMethodDescriptionbooleandelay()A delay request can succeed only if: there is no other pending delay request there is no pending execution requestlonglongprotected ActiveMQThreadFactorybooleansetInitialDelay(long initialDelay) setInitialDelayAndPeriod(long initialDelay, long period) Useful to change a running schedule and avoid multiple restarts.setInitialDelayAndPeriod(long initialDelay, long period, TimeUnit timeUnit) Useful to change a running schedule and avoid multiple restarts.setPeriod(long period) setTimeUnit(TimeUnit timeUnit) voidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.activemq.artemis.core.server.ActiveMQComponent
asyncStop
-
Field Details
-
scheduledExecutorService
-
executor
-
-
Constructor Details
-
ActiveMQScheduledComponent
public ActiveMQScheduledComponent(ScheduledExecutorService scheduledExecutorService, Executor executor, long initialDelay, long checkPeriod, 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(ScheduledExecutorService scheduledExecutorService, long initialDelay, long checkPeriod, 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(ScheduledExecutorService scheduledExecutorService, Executor executor, long checkPeriod, 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, 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
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 Details
-
start
public void start()- Specified by:
startin interfaceActiveMQComponent
-
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
-
setPeriod
-
getInitialDelay
public long getInitialDelay() -
setInitialDelay
-
setInitialDelayAndPeriod
Useful to change a running schedule and avoid multiple restarts. -
setInitialDelayAndPeriod
public ActiveMQScheduledComponent setInitialDelayAndPeriod(long initialDelay, long period, TimeUnit timeUnit) Useful to change a running schedule and avoid multiple restarts. -
getTimeUnit
-
setTimeUnit
-
stop
public void stop()- Specified by:
stopin interfaceActiveMQComponent
-
isStarted
public boolean isStarted()- Specified by:
isStartedin interfaceActiveMQComponent
-