Class QMUX

All Implemented Interfaces:
Configurable, ISOSource, MUX, QMUXMBean, QBean, QBeanSupportMBean, QPersist, SpaceListener, Loggeable, MetricsProvider

A Q2-managed multiplexer that routes ISO messages between channels and listeners.
  • Field Details

    • sp

      protected LocalSpace sp
      Local space backing the in/out queues.
    • in

      protected String in
      Queue names: inbound responses, outbound requests, and unhandled messages.
    • out

      protected String out
      Queue names: inbound responses, outbound requests, and unhandled messages.
    • unhandled

      protected String unhandled
      Queue names: inbound responses, outbound requests, and unhandled messages.
    • ready

      protected String[] ready
      Optional list of "ready indicator" keys polled to determine connectivity.
    • key

      protected String[] key
      Default field-number key components used to correlate responses.
    • ignorerc

      protected String ignorerc
      Comma-separated response codes to ignore (treat as if no response was received).
    • mtiMapping

      protected String[] mtiMapping
      Three-character MTI mapping table used by mapMTI(String).
  • Constructor Details

    • QMUX

      public QMUX()
      Default constructor.
  • 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
    • startService

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

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

      public void destroyService()
      Description copied from class: QBeanSupport
      Called during the destroy lifecycle phase; subclasses may override.
      Overrides:
      destroyService in class QBeanSupport
    • getMUX

      public static MUX getMUX(String name) throws NameRegistrar.NotFoundException
      Returns the MUX registered under the given name.
      Parameters:
      name - MUX name (without the mux. prefix)
      Returns:
      MUX with name using NameRegistrar
      Throws:
      NameRegistrar.NotFoundException - if not found in registry
      See Also:
    • 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 - amount of time in millis to wait for a response
      Returns:
      response or null
      Throws:
      ISOException - on pack/unpack error
    • request

      public void request(ISOMsg m, long timeout, ISOResponseListener rl, 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
      rl - reference to response listener
      handBack - optional handback to be given to reponse listener
      Throws:
      ISOException - on pack/unpack error
    • isNotifyEligible

      protected boolean isNotifyEligible(ISOMsg msg)
      Returns whether msg should be considered for response-matching by notify(Object, Object).
      Parameters:
      msg - message just dequeued from the inbound space
      Returns:
      true when the message should be matched against pending requests
    • notify

      public void notify(Object k, Object value)
      Description copied from interface: SpaceListener

      Called by Space implementation whenever an object with the given key is being placed in the Space.

      Specified by:
      notify in interface SpaceListener
      Parameters:
      k - Object's key
      value - Object's value
    • getKey

      public String getKey(ISOMsg m) throws ISOException
      Builds the correlation key used to pair a response with its request, applying any per-MTI/per-PCODE overrides and special-cases for STAN/PAN fields.
      Parameters:
      m - message whose key should be derived
      Returns:
      the computed key (queue prefix + MTI + selected field values)
      Throws:
      ISOException - if no key fields are present in m
    • getMetrics

      public Metrics getMetrics()
      Description copied from interface: MetricsProvider
      Returns the metrics aggregator owned by this component.
      Specified by:
      getMetrics in interface MetricsProvider
      Returns:
      the live Metrics instance
    • setInQueue

      public void setInQueue(String in)
      Description copied from interface: QMUXMBean
      Sets the inbound (response) queue name.
      Specified by:
      setInQueue in interface QMUXMBean
      Parameters:
      in - queue name
    • getInQueue

      public String getInQueue()
      Description copied from interface: QMUXMBean
      Returns the inbound (response) queue name.
      Specified by:
      getInQueue in interface QMUXMBean
      Returns:
      queue name
    • setOutQueue

      public void setOutQueue(String out)
      Description copied from interface: QMUXMBean
      Sets the outbound (request) queue name.
      Specified by:
      setOutQueue in interface QMUXMBean
      Parameters:
      out - queue name
    • getOutQueue

      public String getOutQueue()
      Description copied from interface: QMUXMBean
      Returns the outbound (request) queue name.
      Specified by:
      getOutQueue in interface QMUXMBean
      Returns:
      queue name
    • getSpace

      public Space getSpace()
      Returns the Space backing this MUX's queues.
      Returns:
      the local space
    • setUnhandledQueue

      public void setUnhandledQueue(String unhandled)
      Description copied from interface: QMUXMBean
      Sets the queue name where unmatched inbound messages are forwarded.
      Specified by:
      setUnhandledQueue in interface QMUXMBean
      Parameters:
      unhandled - queue name
    • getUnhandledQueue

      Description copied from interface: QMUXMBean
      Returns the queue name where unmatched inbound messages are forwarded.
      Specified by:
      getUnhandledQueue in interface QMUXMBean
      Returns:
      queue name, or null if not configured
    • getReadyIndicatorNames

      Returns the configured ready-indicator key names polled to determine connectivity.
      Returns:
      the ready indicator names, or null if none were configured
    • addISORequestListener

      Registers a request listener invoked for messages that don't match a pending request.
      Parameters:
      l - listener to add
    • removeISORequestListener

      Removes a previously registered request listener.
      Parameters:
      l - listener to remove
      Returns:
      true if the listener was registered, false otherwise
    • resetCounters

      public void resetCounters()
      Resets all in-memory transaction counters and the last-transaction timestamp.
      Specified by:
      resetCounters in interface QMUXMBean
    • getCountersAsString

      Returns the current counters formatted as a single human-readable string.
      Specified by:
      getCountersAsString in interface QMUXMBean
      Returns:
      a comma-separated counter snapshot suitable for diagnostics
    • getTXCounter

      public int getTXCounter()
      Description copied from interface: QMUXMBean
      Returns the number of messages transmitted since the last reset.
      Specified by:
      getTXCounter in interface QMUXMBean
      Returns:
      TX message count
    • getRXCounter

      public int getRXCounter()
      Description copied from interface: QMUXMBean
      Returns the number of messages received since the last reset.
      Specified by:
      getRXCounter in interface QMUXMBean
      Returns:
      RX message count
    • getTXExpired

      public int getTXExpired()
      Description copied from interface: QMUXMBean
      Returns the number of TX requests that expired without a matching response.
      Specified by:
      getTXExpired in interface QMUXMBean
      Returns:
      expired TX count
    • getTXPending

      public int getTXPending()
      Description copied from interface: QMUXMBean
      Returns the number of TX requests still awaiting a response.
      Specified by:
      getTXPending in interface QMUXMBean
      Returns:
      pending TX count
    • getRXExpired

      public int getRXExpired()
      Description copied from interface: QMUXMBean
      Returns the number of received responses that arrived too late and were discarded.
      Specified by:
      getRXExpired in interface QMUXMBean
      Returns:
      expired RX count
    • getRXPending

      public int getRXPending()
      Description copied from interface: QMUXMBean
      Returns the number of in-flight responses awaiting matching.
      Specified by:
      getRXPending in interface QMUXMBean
      Returns:
      pending RX count
    • getRXUnhandled

      public int getRXUnhandled()
      Description copied from interface: QMUXMBean
      Returns the number of received messages that did not match any pending request.
      Specified by:
      getRXUnhandled in interface QMUXMBean
      Returns:
      unhandled RX count
    • getRXForwarded

      public int getRXForwarded()
      Description copied from interface: QMUXMBean
      Returns the number of unmatched messages successfully forwarded to listeners.
      Specified by:
      getRXForwarded in interface QMUXMBean
      Returns:
      forwarded RX count
    • getLastTxnTimestampInMillis

      Description copied from interface: QMUXMBean
      Returns the wall-clock timestamp of the last successful transaction.
      Specified by:
      getLastTxnTimestampInMillis in interface QMUXMBean
      Returns:
      milliseconds since the epoch, or 0 if no transaction has completed
    • getIdleTimeInMillis

      public long getIdleTimeInMillis()
      Description copied from interface: QMUXMBean
      Returns the time elapsed since the last successful transaction.
      Specified by:
      getIdleTimeInMillis in interface QMUXMBean
      Returns:
      idle time in milliseconds, or -1 if no transaction has completed
    • processUnhandled

      protected void processUnhandled(ISOMsg m)
      Dispatches an inbound message that did not match any pending request, giving registered request listeners a chance to handle it before falling back to the configured unhandled queue.
      Parameters:
      m - the unmatched inbound message
    • send

      public void send(ISOMsg m) throws IOException, ISOException
      sends (or hands back) an ISOMsg
      Specified by:
      send in interface ISOSource
      Parameters:
      m - the Message to be sent
      Throws:
      IOException - if the underlying space cannot accept the message
      ISOException - on pack/unpack error
      ISOFilter.VetoException - if a filter vetoes the message
    • 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
    • dump

      public void dump(PrintStream p, String indent)
      Description copied from interface: Loggeable
      Dumps a human-readable representation of this object to the print stream.
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - the output stream
      indent - indentation prefix