Class QMUX
java.lang.Object
org.jpos.q2.QBeanSupport
org.jpos.q2.iso.QMUX
- All Implemented Interfaces:
Configurable, ISOSource, MUX, QMUXMBean, QBean, QBeanSupportMBean, QPersist, SpaceListener, Loggeable, MetricsProvider
public class QMUX
extends QBeanSupport
implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider
A Q2-managed multiplexer that routes ISO messages between channels and listeners.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassTracks an asynchronous request awaiting a response, with optional timeout scheduling and elapsed-time measurement. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringComma-separated response codes to ignore (treat as if no response was received).protected StringQueue names: inbound responses, outbound requests, and unhandled messages.protected String[]Default field-number key components used to correlate responses.protected String[]Three-character MTI mapping table used bymapMTI(String).protected StringQueue names: inbound responses, outbound requests, and unhandled messages.protected String[]Optional list of "ready indicator" keys polled to determine connectivity.protected LocalSpaceLocal space backing the in/out queues.protected StringQueue names: inbound responses, outbound requests, and unhandled messages.Fields inherited from class QBeanSupport
cfg, log, scheduledThreadPoolExecutorModifier and TypeFieldDescriptionprotected ConfigurationConfiguration applied to this bean by the container.protected LogLogger associated with this bean.protected ScheduledThreadPoolExecutorLazily-allocated scheduler shared with subclasses; seeQBeanSupport.getScheduledThreadPoolExecutor().Fields inherited from interface QBean
DESTROYED, FAILED, STARTED, STARTING, stateString, STOPPED, STOPPINGModifier and TypeFieldDescriptionstatic final intQBean has been destroyed.static final intQBean has failed.static final intQBean is running.static final intQBean is in the process of starting.static final String[]Human-readable names for each QBean state, indexed by state constant.static final intQBean is stopped.static final intQBean is in the process of stopping. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a request listener invoked for messages that don't match a pending request.protected StringReturns the default realm for this bean; subclasses may override.voidCalled during the destroy lifecycle phase; subclasses may override.voiddump(PrintStream p, String indent) Dumps a human-readable representation of this object to the print stream.Returns the current counters formatted as a single human-readable string.longReturns the time elapsed since the last successful transaction.Returns the inbound (response) queue name.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.longReturns the wall-clock timestamp of the last successful transaction.Returns the metrics aggregator owned by this component.static MUXReturns the MUX registered under the given name.Returns the outbound (request) queue name.String[]Returns the configured ready-indicator key names polled to determine connectivity.intReturns the number of messages received since the last reset.intReturns the number of received responses that arrived too late and were discarded.intReturns the number of unmatched messages successfully forwarded to listeners.intReturns the number of in-flight responses awaiting matching.intReturns the number of received messages that did not match any pending request.getSpace()Returns theSpacebacking this MUX's queues.intReturns the number of messages transmitted since the last reset.intReturns the number of TX requests that expired without a matching response.intReturns the number of TX requests still awaiting a response.Returns the queue name where unmatched inbound messages are forwarded.voidCalled during the init lifecycle phase; subclasses may override.booleanIndicates whether this source is currently connected and able to send messages.protected booleanisNotifyEligible(ISOMsg msg) Returns whethermsgshould be considered for response-matching bynotify(Object, Object).voidCalled by Space implementation whenever an object with the given key is being placed in the Space.protected voidDispatches an inbound message that did not match any pending request, giving registered request listeners a chance to handle it before falling back to the configuredunhandledqueue.booleanRemoves a previously registered request listener.Sends a message to remote host and wait for responsevoidrequest(ISOMsg m, long timeout, ISOResponseListener rl, Object handBack) Sends a message to remote host in async wayvoidResets all in-memory transaction counters and the last-transaction timestamp.voidsends (or hands back) an ISOMsgvoidsetInQueue(String in) Sets the inbound (response) queue name.voidsetOutQueue(String out) Sets the outbound (request) queue name.voidsetUnhandledQueue(String unhandled) Sets the queue name where unmatched inbound messages are forwarded.voidCalled during the start lifecycle phase; subclasses may override.voidCalled during the stop lifecycle phase; subclasses may override.Methods inherited from class QBeanSupport
addAttr, close, createElement, destroy, getAttrs, getAttrs, getConfiguration, getDump, getFactory, getLoader, getLoaderURLS, getLog, getLogger, getName, getPersist, getProperties, getProperty, getRealm, getScheduledThreadPoolExecutor, getServer, getState, getStateAsString, init, isModified, running, setAttr, setConfiguration, setLogger, setModified, setName, setPersist, setProperty, setRealm, setServer, setState, start, stopModifier and TypeMethodDescriptionprotected voidAppends an<attr>child element with name/type/value toe.protected voidCloses a sequence ofCloseableresources, logging any failures as a warning.protected org.jdom2.ElementcreateElement(String name, Class mbeanClass) Builds a JDOMElementreflecting the bean's persistent attributes, driven by the JavaBean introspection ofmbeanClass.voiddestroy()destroy the serviceprotected IteratorgetAttrs()Iterates over top-level<attr>children of the persisted element.protected IteratorIterates over<attr>children nested under the given parent element name.Returns the configuration applied to this bean.getDump()Returns a textual dump of this bean's state.Returns theQFactoryassociated with the hosting Q2 server.Returns the QClassLoader for this bean.URL[]Returns the URLs registered with the class loader.getLog()Returns theLogused by this bean.Returns the logger name.getName()Returns the bean name.org.jdom2.ElementReturns the persistent configuration element for this QBean.protected IteratorgetProperties(String parent) Iterates over<property>children nested under the given parent element name.protected StringgetProperty(Iterator props, String name) Returns the value of the named property from an iterator of<property>elements.getRealm()Returns the logging realm.protected ScheduledThreadPoolExecutorLazily creates and returns aScheduledThreadPoolExecutorfor use by subclasses.Returns the Q2 server instance.intgetState()Returns the current state of this QBean.Returns the current state as a human-readable string.voidinit()init the servicebooleanReturnstrueif this QBean's configuration has been modified since last save.booleanrunning()Indicates whether this bean is currently starting or running.protected voidUpdates the value of the named attribute within an iterator of<attr>elements.voidConfigures this object with the suppliedConfiguration.voidSets the logger by name.voidsetModified(boolean modified) Marks this bean's persistent state as modified or in sync.voidSets the bean name.voidsetPersist(org.jdom2.Element persist) Sets the persistent configuration element.protected voidsetProperty(Iterator props, String name, String value) Updates the value attribute of the named property within an iterator of<property>elements.voidSets the logging realm.voidSets the Q2 server instance for this QBean.voidsetState(int state) Sets the lifecycle state of this bean.voidstart()start the servicevoidstop()stop the serviceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Loggeable
dumpModifier and TypeMethodDescriptiondefault voiddump(PrintStream p, String indent, LogRenderer.Type type) Dumps a representation of this object using the specified renderer type.
-
Field Details
-
sp
Local space backing the in/out queues. -
in
-
out
-
unhandled
-
ready
-
key
-
ignorerc
-
mtiMapping
Three-character MTI mapping table used bymapMTI(String).
-
-
Constructor Details
-
QMUX
public QMUX()Default constructor.
-
-
Method Details
-
defaultRealm
Description copied from class:QBeanSupportReturns the default realm for this bean; subclasses may override.- Overrides:
defaultRealmin classQBeanSupport- Returns:
- default realm string, or null
-
initService
Description copied from class:QBeanSupportCalled during the init lifecycle phase; subclasses may override.- Overrides:
initServicein classQBeanSupport- Throws:
ConfigurationException
-
startService
Description copied from class:QBeanSupportCalled during the start lifecycle phase; subclasses may override.- Overrides:
startServicein classQBeanSupport
-
stopService
Description copied from class:QBeanSupportCalled during the stop lifecycle phase; subclasses may override.- Overrides:
stopServicein classQBeanSupport
-
destroyService
Description copied from class:QBeanSupportCalled during the destroy lifecycle phase; subclasses may override.- Overrides:
destroyServicein classQBeanSupport
-
getMUX
Returns the MUX registered under the given name.- Parameters:
name- MUX name (without themux.prefix)- Returns:
- MUX with name using NameRegistrar
- Throws:
NameRegistrar.NotFoundException- if not found in registry- See Also:
-
request
Description copied from interface:MUXSends a message to remote host and wait for response- Specified by:
requestin interfaceMUX- Parameters:
m- message to sendtimeout- 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:MUXSends a message to remote host in async way- Specified by:
requestin interfaceMUX- Parameters:
m- message to sendtimeout- time to wait for the responserl- reference to response listenerhandBack- optional handback to be given to reponse listener- Throws:
ISOException- on pack/unpack error
-
isNotifyEligible
Returns whethermsgshould be considered for response-matching bynotify(Object, Object).- Parameters:
msg- message just dequeued from the inbound space- Returns:
truewhen the message should be matched against pending requests
-
notify
Description copied from interface:SpaceListenerCalled by Space implementation whenever an object with the given key is being placed in the Space.
- Specified by:
notifyin interfaceSpaceListener- Parameters:
k- Object's keyvalue- Object's value
-
getKey
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 inm
-
getMetrics
Description copied from interface:MetricsProviderReturns the metrics aggregator owned by this component.- Specified by:
getMetricsin interfaceMetricsProvider- Returns:
- the live
Metricsinstance
-
setInQueue
Description copied from interface:QMUXMBeanSets the inbound (response) queue name.- Specified by:
setInQueuein interfaceQMUXMBean- Parameters:
in- queue name
-
getInQueue
Description copied from interface:QMUXMBeanReturns the inbound (response) queue name.- Specified by:
getInQueuein interfaceQMUXMBean- Returns:
- queue name
-
setOutQueue
Description copied from interface:QMUXMBeanSets the outbound (request) queue name.- Specified by:
setOutQueuein interfaceQMUXMBean- Parameters:
out- queue name
-
getOutQueue
Description copied from interface:QMUXMBeanReturns the outbound (request) queue name.- Specified by:
getOutQueuein interfaceQMUXMBean- Returns:
- queue name
-
getSpace
-
setUnhandledQueue
Description copied from interface:QMUXMBeanSets the queue name where unmatched inbound messages are forwarded.- Specified by:
setUnhandledQueuein interfaceQMUXMBean- Parameters:
unhandled- queue name
-
getUnhandledQueue
Description copied from interface:QMUXMBeanReturns the queue name where unmatched inbound messages are forwarded.- Specified by:
getUnhandledQueuein interfaceQMUXMBean- Returns:
- queue name, or
nullif not configured
-
getReadyIndicatorNames
Returns the configured ready-indicator key names polled to determine connectivity.- Returns:
- the ready indicator names, or
nullif 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:
trueif the listener was registered,falseotherwise
-
resetCounters
Resets all in-memory transaction counters and the last-transaction timestamp.- Specified by:
resetCountersin interfaceQMUXMBean
-
getCountersAsString
Returns the current counters formatted as a single human-readable string.- Specified by:
getCountersAsStringin interfaceQMUXMBean- Returns:
- a comma-separated counter snapshot suitable for diagnostics
-
getTXCounter
Description copied from interface:QMUXMBeanReturns the number of messages transmitted since the last reset.- Specified by:
getTXCounterin interfaceQMUXMBean- Returns:
- TX message count
-
getRXCounter
Description copied from interface:QMUXMBeanReturns the number of messages received since the last reset.- Specified by:
getRXCounterin interfaceQMUXMBean- Returns:
- RX message count
-
getTXExpired
Description copied from interface:QMUXMBeanReturns the number of TX requests that expired without a matching response.- Specified by:
getTXExpiredin interfaceQMUXMBean- Returns:
- expired TX count
-
getTXPending
Description copied from interface:QMUXMBeanReturns the number of TX requests still awaiting a response.- Specified by:
getTXPendingin interfaceQMUXMBean- Returns:
- pending TX count
-
getRXExpired
Description copied from interface:QMUXMBeanReturns the number of received responses that arrived too late and were discarded.- Specified by:
getRXExpiredin interfaceQMUXMBean- Returns:
- expired RX count
-
getRXPending
Description copied from interface:QMUXMBeanReturns the number of in-flight responses awaiting matching.- Specified by:
getRXPendingin interfaceQMUXMBean- Returns:
- pending RX count
-
getRXUnhandled
Description copied from interface:QMUXMBeanReturns the number of received messages that did not match any pending request.- Specified by:
getRXUnhandledin interfaceQMUXMBean- Returns:
- unhandled RX count
-
getRXForwarded
Description copied from interface:QMUXMBeanReturns the number of unmatched messages successfully forwarded to listeners.- Specified by:
getRXForwardedin interfaceQMUXMBean- Returns:
- forwarded RX count
-
getLastTxnTimestampInMillis
Description copied from interface:QMUXMBeanReturns the wall-clock timestamp of the last successful transaction.- Specified by:
getLastTxnTimestampInMillisin interfaceQMUXMBean- Returns:
- milliseconds since the epoch, or
0if no transaction has completed
-
getIdleTimeInMillis
Description copied from interface:QMUXMBeanReturns the time elapsed since the last successful transaction.- Specified by:
getIdleTimeInMillisin interfaceQMUXMBean- Returns:
- idle time in milliseconds, or
-1if no transaction has completed
-
processUnhandled
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 configuredunhandledqueue.- Parameters:
m- the unmatched inbound message
-
send
sends (or hands back) an ISOMsg- Specified by:
sendin interfaceISOSource- Parameters:
m- the Message to be sent- Throws:
IOException- if the underlying space cannot accept the messageISOException- on pack/unpack errorISOFilter.VetoException- if a filter vetoes the message
-
isConnected
Description copied from interface:ISOSourceIndicates whether this source is currently connected and able to send messages.- Specified by:
isConnectedin interfaceISOSource- Returns:
- true if source is connected and usable
-
dump
-