Class BatchProcessor

  • All Implemented Interfaces:
    Runnable

    public class BatchProcessor
    extends TimerTask
    TimerTask to maintain the events queue and send it to moesif periodically. Task runner method sends event in batches if at least one batch of events available. It maintains : 1. queue to hold events and events related configuration settings. 2. flag to show if a job is in-progress/running. It prints few helpful log statements, if debug has been enabled.
    • Constructor Detail

      • BatchProcessor

        public BatchProcessor​(com.moesif.api.MoesifAPIClient moesifApi,
                              MoesifConfiguration moesifConfig,
                              boolean debug)
    • Method Detail

      • getBatchMaxTime

        public int getBatchMaxTime()
        Returns time in seconds
        Returns:
      • getUpdateConfigTime

        public int getUpdateConfigTime()
        Returns time in seconds
        Returns:
      • addEvent

        public void addEvent​(com.moesif.api.models.EventModel event)
        Method to add event into a queue for batch-based event transfer. It maintains time when the last event was added to the event queue.
        Parameters:
        event - : EventModel
      • isJobRunning

        public boolean isJobRunning()
        Method to check if job is running or not.
        Returns:
        boolean Returns true if job is running otherwise false.
      • run

        public void run()
        Task runner method to send events in batches if at least a batch of events available. It also keeps track of a flag to show if job is in-progress. If debug has been enabled then it prints how many batches were sent with total events count.
        Specified by:
        run in interface Runnable
        Specified by:
        run in class TimerTask