Enum NextReceiverPolicy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<NextReceiverPolicy>

    public enum NextReceiverPolicy
    extends java.lang.Enum<NextReceiverPolicy>
    Determines the behavior of a Session when the next receiver method is called on that session. Each policy provides a contract on the ordering of returned receivers from the next receiver API when there are receivers with locally queued deliveries. When there are no Receiver instances that have locally queued deliveries the next receive API will return the next receiver to receive a complete incoming delivery unless a timeout was given and that time period expires in which case it will return null.

    Should the user perform receive calls on a Receiver directly in multiple threads the behavior of the next receiver API is undefined and it becomes possible that the resulting receiver returned from that API will have no actual pending deliveries due to a race. In most cases the caller can mitigate some risk by using the Receiver.tryReceive() API and accounting for a null result.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      FIRST_AVAILABLE
      Examines the list of currently open receivers in the session and returns the first receiver found with an available delivery.
      LARGEST_BACKLOG
      Examines the list of currently open receivers in the session and returns the receiver with the largest backlog of available deliveries.
      RANDOM
      Examines the list of currently open receivers in the session and returns a random selection from the set of receivers that have a pending delivery immediately available.
      ROUND_ROBIN
      Examines the list of currently open receivers in the session and returns the next receiver that has a pending delivery that follows the previously returned receiver (if any) otherwise the first receiver in the session with a pending delivery is returned.
      SMALLEST_BACKLOG
      Examines the list of currently open receivers in the session and returns the receiver with the smallest backlog of available deliveries.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static NextReceiverPolicy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static NextReceiverPolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • ROUND_ROBIN

        public static final NextReceiverPolicy ROUND_ROBIN
        Examines the list of currently open receivers in the session and returns the next receiver that has a pending delivery that follows the previously returned receiver (if any) otherwise the first receiver in the session with a pending delivery is returned. The order of receivers returned will likely be creation order however the implementation is not required to follow this pattern so the caller should not be coded to rely on that ordering.
      • RANDOM

        public static final NextReceiverPolicy RANDOM
        Examines the list of currently open receivers in the session and returns a random selection from the set of receivers that have a pending delivery immediately available. This provides a means of selecting receivers which is not prone to sticking to a highly active receiver which can starve out other receivers which receive only limited traffic.
      • FIRST_AVAILABLE

        public static final NextReceiverPolicy FIRST_AVAILABLE
        Examines the list of currently open receivers in the session and returns the first receiver found with an available delivery. This can result in starvation if that receiver has a continuous feed of new deliveries from the remote as it will be repeatedly selected by the next receiver API.
      • LARGEST_BACKLOG

        public static final NextReceiverPolicy LARGEST_BACKLOG
        Examines the list of currently open receivers in the session and returns the receiver with the largest backlog of available deliveries. This can result in starvation if that receiver has a continuous feed of new deliveries from the remote as it will likely be repeatedly selected by the next receiver API.
      • SMALLEST_BACKLOG

        public static final NextReceiverPolicy SMALLEST_BACKLOG
        Examines the list of currently open receivers in the session and returns the receiver with the smallest backlog of available deliveries.
    • Method Detail

      • values

        public static NextReceiverPolicy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (NextReceiverPolicy c : NextReceiverPolicy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static NextReceiverPolicy valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null