Class InMemoryJobScheduler

java.lang.Object
org.apache.activemq.broker.scheduler.memory.InMemoryJobScheduler
All Implemented Interfaces:
JobScheduler

public class InMemoryJobScheduler extends Object implements JobScheduler
Implements an in-memory JobScheduler instance.
  • Constructor Details

    • InMemoryJobScheduler

      public InMemoryJobScheduler(String name)
  • Method Details

    • getName

      public String getName() throws Exception
      Specified by:
      getName in interface JobScheduler
      Returns:
      the name of the scheduler
      Throws:
      Exception
    • start

      public void start() throws Exception
      Throws:
      Exception
    • stop

      public void stop() throws Exception
      Throws:
      Exception
    • isStarted

      public boolean isStarted()
    • isDispatchEnabled

      public boolean isDispatchEnabled()
    • startDispatching

      public void startDispatching() throws Exception
      Description copied from interface: JobScheduler
      Starts dispatch of scheduled Jobs to registered listeners. Any listener added after the start dispatch method can miss jobs so its important to register critical listeners before the start of job dispatching.
      Specified by:
      startDispatching in interface JobScheduler
      Throws:
      Exception
    • stopDispatching

      public void stopDispatching() throws Exception
      Description copied from interface: JobScheduler
      Stops dispatching of scheduled Jobs to registered listeners.
      Specified by:
      stopDispatching in interface JobScheduler
      Throws:
      Exception
    • addListener

      public void addListener(JobListener listener) throws Exception
      Description copied from interface: JobScheduler
      Add a Job listener which will receive events related to scheduled jobs.
      Specified by:
      addListener in interface JobScheduler
      Parameters:
      listener - The job listener to add.
      Throws:
      Exception
    • removeListener

      public void removeListener(JobListener listener) throws Exception
      Description copied from interface: JobScheduler
      remove a JobListener that was previously registered. If the given listener is not in the registry this method has no effect.
      Specified by:
      removeListener in interface JobScheduler
      Parameters:
      listener - The listener that should be removed from the listener registry.
      Throws:
      Exception
    • schedule

      public void schedule(String jobId, org.apache.activemq.util.ByteSequence payload, long delay) throws Exception
      Description copied from interface: JobScheduler
      Add a job to be scheduled
      Specified by:
      schedule in interface JobScheduler
      Parameters:
      jobId - a unique identifier for the job
      payload - the message to be sent when the job is scheduled
      delay - the time in milliseconds before the job will be run
      Throws:
      Exception - if an error occurs while scheduling the Job.
    • schedule

      public void schedule(String jobId, org.apache.activemq.util.ByteSequence payload, String cronEntry) throws Exception
      Description copied from interface: JobScheduler
      Add a job to be scheduled
      Specified by:
      schedule in interface JobScheduler
      Parameters:
      jobId - a unique identifier for the job
      payload - the message to be sent when the job is scheduled
      cronEntry - The cron entry to use to schedule this job.
      Throws:
      Exception - if an error occurs while scheduling the Job.
    • schedule

      public void schedule(String jobId, org.apache.activemq.util.ByteSequence payload, String cronEntry, long delay, long period, int repeat) throws Exception
      Description copied from interface: JobScheduler
      Add a job to be scheduled
      Specified by:
      schedule in interface JobScheduler
      Parameters:
      jobId - a unique identifier for the job
      payload - the message to be sent when the job is scheduled
      cronEntry - cron entry
      delay - time in ms to wait before scheduling
      period - the time in milliseconds between successive executions of the Job
      repeat - the number of times to execute the job - less than 0 will be repeated forever
      Throws:
      Exception
    • remove

      public void remove(long time) throws Exception
      Description copied from interface: JobScheduler
      remove all jobs scheduled to run at this time
      Specified by:
      remove in interface JobScheduler
      Parameters:
      time - The UTC time to use to remove a batch of scheduled Jobs.
      Throws:
      Exception
    • remove

      public void remove(String jobId) throws Exception
      Description copied from interface: JobScheduler
      remove a job with the matching jobId
      Specified by:
      remove in interface JobScheduler
      Parameters:
      jobId - The unique Job Id to search for and remove from the scheduled set of jobs.
      Throws:
      Exception - if an error occurs while removing the Job.
    • removeAllJobs

      public void removeAllJobs() throws Exception
      Description copied from interface: JobScheduler
      remove all the Jobs from the scheduler
      Specified by:
      removeAllJobs in interface JobScheduler
      Throws:
      Exception
    • removeAllJobs

      public void removeAllJobs(long start, long finish) throws Exception
      Description copied from interface: JobScheduler
      remove all the Jobs from the scheduler that are due between the start and finish times
      Specified by:
      removeAllJobs in interface JobScheduler
      Parameters:
      start - time in milliseconds
      finish - time in milliseconds
      Throws:
      Exception
    • getNextScheduleTime

      public long getNextScheduleTime() throws Exception
      Description copied from interface: JobScheduler
      Get the next time jobs will be fired
      Specified by:
      getNextScheduleTime in interface JobScheduler
      Returns:
      the time in milliseconds
      Throws:
      Exception
    • getNextScheduleJobs

      public List<Job> getNextScheduleJobs() throws Exception
      Description copied from interface: JobScheduler
      Get all the jobs scheduled to run next
      Specified by:
      getNextScheduleJobs in interface JobScheduler
      Returns:
      a list of jobs that will be scheduled next
      Throws:
      Exception
    • getAllJobs

      public List<Job> getAllJobs() throws Exception
      Description copied from interface: JobScheduler
      Get all the outstanding Jobs
      Specified by:
      getAllJobs in interface JobScheduler
      Returns:
      a list of all jobs
      Throws:
      Exception
    • getAllJobs

      public List<Job> getAllJobs(long start, long finish) throws Exception
      Description copied from interface: JobScheduler
      Get all outstanding jobs due to run between start and finish
      Specified by:
      getAllJobs in interface JobScheduler
      Returns:
      a list of jobs
      Throws:
      Exception
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object