Class TimeUnitChangeLimit

java.lang.Object
com.swiftmq.impl.streams.comp.memory.limit.TimeUnitChangeLimit
All Implemented Interfaces:
Limit

public class TimeUnitChangeLimit extends Object implements Limit
A TimeUnitChangeLimit keeps a Memory at a specific time unit window (e.g. 1 hour based on midnight) and removes older Messages if necessary.

The time unit window's time is based as follows (MM/DD/YYYY):

  • seconds: based on minute, e.g. 10 secs at time 18:12:17 starts at 18:12:10
  • minutes: based on hour, e.g. 5 mins at time 18:12:17 starts at 18:10:00
  • days: based on month, e.g. 2 days at 04/17/2017 starts at 04/16/2017
  • weeks: based on year, e.g. 2 weeks at 01/15/2017 starts at 01/14/2017
  • months: based on year, e.g. 3 month at 05/10/2017 starts at 04/01/2017
  • years: based on year, e.g. 2 years at 05/10/2017 starts at 01/01/2017

The difference between this time unit limit and a time limit is that the time limit has the window base at the time when it is started, e.g. started at 18:12:17 with a 10 secs window has a window from 18:12:17 to 18:12:27 exclusive.

A time unit change limit, however, has a fixed base and synchronizes the first window to it. For example, a 10 secs window started at 18:12:17 has a window start at 18:12:10 and ends therefore at 18:12:20 (exclusive). So this first window is only 13 secs long. The following windows will have full 10 secs. This is useful to synchronize events on fixed base times (full seconds/minutes/hours etc).

A time unit limt can only have one time unit, e.g. it is not possible to chain units like seconds(10).minutes(5).

Author:
IIT Software GmbH, Muenster/Germany, (c) 2017, All Rights Reserved
  • Constructor Details

    • TimeUnitChangeLimit

      public TimeUnitChangeLimit(StreamContext ctx, Memory memory)
      Internal use only.
  • Method Details

    • seconds

      public TimeUnitChangeLimit seconds(int n)
      Sets a seconds time unit limit
      Parameters:
      n - number of seconds
      Returns:
      this
    • minutes

      public TimeUnitChangeLimit minutes(int n)
      Sets a minutes time unit limit
      Parameters:
      n - number of minutes
      Returns:
      this
    • hours

      public TimeUnitChangeLimit hours(int n)
      Sets a hours time unit limit
      Parameters:
      n - number of hours
      Returns:
      this
    • days

      public TimeUnitChangeLimit days(int n)
      Sets a days time unit limit
      Parameters:
      n - number of days
      Returns:
      this
    • weeks

      public TimeUnitChangeLimit weeks(int n)
      Sets a weeks time unit limit
      Parameters:
      n - number of weeks
      Returns:
      this
    • months

      public TimeUnitChangeLimit months(int n)
      Sets a months time unit limit
      Parameters:
      n - number of months
      Returns:
      this
    • years

      public TimeUnitChangeLimit years(int n)
      Sets a years time unit limit
      Parameters:
      n - number of years
      Returns:
      this
    • checkLimit

      public void checkLimit()
      Description copied from interface: Limit
      Checks the Memory limits and deletes Messages that doesn't fit in the limit
      Specified by:
      checkLimit in interface Limit
    • onRetire

      public Limit onRetire(RetirementCallback callback)
      Description copied from interface: Limit
      Sets a callback which is called for each Message that is retired (removed by a Limit).
      Specified by:
      onRetire in interface Limit
      Parameters:
      callback - Callback
      Returns:
      Limit
    • limit

      public LimitBuilder limit()
      Description copied from interface: Limit
      Creates a new LimitBuilder and that chains new Limits to the corresponding Memory
      Specified by:
      limit in interface Limit
      Returns:
      LimitBuilder
    • toString

      public String toString()
      Overrides:
      toString in class Object