Package io.mats3

Interface MatsStage<R,S,I>

All Superinterfaces:
MatsConfig.StartStoppable

public interface MatsStage<R,S,I> extends MatsConfig.StartStoppable
A representation of a process stage of a MatsEndpoint. Either constructed implicitly (for single-stage endpoints, and terminators), or by invoking the MatsEndpoint.stage(...)-methods on multi-stage endpoints.

Note: It should be possible to use instances of MatsStage as keys in a HashMap, i.e. their equals and hashCode should remain stable throughout the life of the MatsFactory - and similar instances but with different MatsFactory are not equals. Depending on the implementation, instance equality may be sufficient.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Provides for both configuring the stage (before it is started), and introspecting the configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    void
    Starts this stage, thereby firing up the queue processing using a set of threads, the number decided by the MatsConfig.getConcurrency() for each stage.
    boolean
    stop(int gracefulShutdownMillis)
    Stops this stage.
    boolean
    waitForReceiving(int timeoutMillis)
    Will wait until at least one processor of the stage has entered its receive-loop.
  • Method Details

    • getStageConfig

      MatsStage.StageConfig<R,S,I> getStageConfig()
      Returns:
      the MatsStage.StageConfig for this stage.
    • getParentEndpoint

      MatsEndpoint<R,S> getParentEndpoint()
      Returns:
      the parent MatsEndpoint.
    • start

      void start()
      Starts this stage, thereby firing up the queue processing using a set of threads, the number decided by the MatsConfig.getConcurrency() for each stage.

      Will generally be invoked implicitly by MatsEndpoint.start(). The only reason for calling this should be if its corresponding stop(int) method has been invoked to stop processing.

      Specified by:
      start in interface MatsConfig.StartStoppable
    • waitForReceiving

      boolean waitForReceiving(int timeoutMillis)
      Will wait until at least one processor of the stage has entered its receive-loop.
      Specified by:
      waitForReceiving in interface MatsConfig.StartStoppable
      Parameters:
      timeoutMillis - number of milliseconds before giving up the wait, returning false. 0 is indefinite wait, negative values are not allowed.
      Returns:
      true if the entity started within the timeout, false if it did not start.
    • stop

      boolean stop(int gracefulShutdownMillis)
      Stops this stage. This may be used to temporarily stop processing of this stage by means of some external monitor/inspecting mechanism (e.g. in cases where it has been showed to produce results that breaks downstream stages or endpoints, or itself produces Dead Letter Queue-entries due to some external problem). It is possible to start() the stage again.
      Specified by:
      stop in interface MatsConfig.StartStoppable
      Parameters:
      gracefulShutdownMillis - number of milliseconds to let the stage processors wait after having asked for them to shut down, and interrupting them if they have not shut down yet.
      Returns:
      true if the running thread(s) were dead when returning, false otherwise.