Class MUXPool

All Implemented Interfaces:
Configurable, ISOSource, MUX, MUXPoolMBean, QBean, QBeanSupportMBean, QPersist

public class MUXPool extends QBeanSupport implements MUX, MUXPoolMBean
Pool of MUX instances that selects a delegate per request based on the configured strategy (one of PRIMARY_SECONDARY, ROUND_ROBIN, ROUND_ROBIN_WITH_OVERRIDE, or SPLIT_BY_DIVISOR).
  • Field Details

  • Constructor Details

    • MUXPool

      public MUXPool()
      Default constructor; no instance state to initialise.
  • Method Details

    • defaultRealm

      protected String defaultRealm()
      Description copied from class: QBeanSupport
      Returns the default realm for this bean; subclasses may override.
      Overrides:
      defaultRealm in class QBeanSupport
      Returns:
      default realm string, or null
    • initService

      public void initService() throws ConfigurationException
      Description copied from class: QBeanSupport
      Called during the init lifecycle phase; subclasses may override.
      Overrides:
      initService in class QBeanSupport
      Throws:
      ConfigurationException
    • stopService

      public void stopService()
      Description copied from class: QBeanSupport
      Called during the stop lifecycle phase; subclasses may override.
      Overrides:
      stopService in class QBeanSupport
    • initHandler

      protected void initHandler(org.jdom2.Element e) throws ConfigurationException
      Instantiates a custom MUXPool.StrategyHandler from an XML configuration element.
      Parameters:
      e - <strategy-handler> element, or null to leave the handler unset
      Throws:
      ConfigurationException - if the handler cannot be instantiated
    • request

      public ISOMsg request(ISOMsg m, long timeout) throws ISOException
      Description copied from interface: MUX
      Sends a message to remote host and wait for response
      Specified by:
      request in interface MUX
      Parameters:
      m - message to send
      timeout - time to wait for a message
      Returns:
      received message or null
      Throws:
      ISOException - on pack/unpack error
    • request

      public void request(ISOMsg m, long timeout, ISOResponseListener r, Object handBack) throws ISOException
      Description copied from interface: MUX
      Sends a message to remote host in async way
      Specified by:
      request in interface MUX
      Parameters:
      m - message to send
      timeout - time to wait for the response
      r - reference to response listener
      handBack - optional handback to be given to reponse listener
      Throws:
      ISOException - on pack/unpack error
    • send

      public void send(ISOMsg m) throws ISOException, IOException
      Description copied from interface: ISOSource
      sends (or hands back) an ISOMsg
      Specified by:
      send in interface ISOSource
      Parameters:
      m - the Message to be sent
      Throws:
      ISOException - on ISO packing failure
      IOException - on I/O failure
    • firstAvailableMUX

      protected MUX firstAvailableMUX(long maxWait)
      Returns the first usable MUX, scanning from index 0 and waiting up to maxWait.
      Parameters:
      maxWait - wall-clock deadline in milliseconds since epoch
      Returns:
      a usable MUX, or null if none became available before the deadline
    • nextAvailableMUX

      protected MUX nextAvailableMUX(int mnumber, long maxWait)
      Returns the next usable MUX starting from mnumber, waiting up to maxWait.
      Parameters:
      mnumber - starting index (round-robin counter)
      maxWait - wall-clock deadline in milliseconds since epoch
      Returns:
      a usable MUX, or null if none became available before the deadline
    • getMuxNames

      public String[] getMuxNames()
      Description copied from interface: MUXPoolMBean
      Returns the names of the MUXes in this pool.
      Specified by:
      getMuxNames in interface MUXPoolMBean
      Returns:
      MUX names
    • getStrategy

      public int getStrategy()
      Description copied from interface: MUXPoolMBean
      Returns the configured selection strategy.
      Specified by:
      getStrategy in interface MUXPoolMBean
      Returns:
      strategy code (see MUXPool strategy constants)
    • getStrategyHandler

      Returns the configured custom strategy handler, if any.
      Returns:
      the MUXPool.StrategyHandler, or null when not configured
    • isConnected

      public boolean isConnected()
      Description copied from interface: ISOSource
      Indicates whether this source is currently connected and able to send messages.
      Specified by:
      isConnected in interface ISOSource
      Returns:
      true if source is connected and usable