Class ActiveMQScheduledComponent
- java.lang.Object
-
- org.apache.activemq.artemis.core.server.ActiveMQScheduledComponent
-
- All Implemented Interfaces:
Runnable,ActiveMQComponent
- Direct Known Subclasses:
NetworkHealthCheck
public abstract class ActiveMQScheduledComponent extends Object implements ActiveMQComponent, Runnable
This is for components with a scheduled at a fixed rate.
-
-
Field Summary
Fields Modifier and Type Field Description protected Executorexecutorprotected ScheduledExecutorServicescheduledExecutorService
-
Constructor Summary
Constructors Constructor Description ActiveMQScheduledComponent(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
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()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, TimeUnit timeUnit)Useful to change a running schedule and avoid multiple restarts.ActiveMQScheduledComponentsetPeriod(long period)ActiveMQScheduledComponentsetPeriod(long period, TimeUnit unit)ActiveMQScheduledComponentsetTimeUnit(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
-
-
-
-
Field Detail
-
scheduledExecutorService
protected ScheduledExecutorService scheduledExecutorService
-
executor
protected final Executor executor
-
-
Constructor Detail
-
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
public ActiveMQScheduledComponent(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. 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, 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, TimeUnit timeUnit)
Useful to change a running schedule and avoid multiple restarts.
-
getTimeUnit
public TimeUnit getTimeUnit()
-
setTimeUnit
public ActiveMQScheduledComponent setTimeUnit(TimeUnit timeUnit)
-
stop
public void stop()
- Specified by:
stopin interfaceActiveMQComponent
-
isStarted
public boolean isStarted()
- Specified by:
isStartedin interfaceActiveMQComponent
-
-