@Test public void testRequestThrowsNullPointerException() throws Throwable { QMUX qMUX = new QMUX(); ISOMsg m = new ISOMsg("testQMUXMti"); try { qMUX.request(m, 100L); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertEquals("Misconfigured QMUX. Please verify out queue is not null.", ex.getMessage(), "ex.getMessage()"); assertNull(qMUX.sp, "qMUX.sp"); assertEquals(0, m.getDirection(), "m.getDirection()"); } }
public ISOMsg request (ISOMsg m, long timeout) throws ISOException { String key = getKey (m); String req = key + ".req"; synchronized (isp) { if (isp.rdp (req) != null) throw new ISOException ("Duplicate key '" + req + "' detected"); isp.out (req, m); } m.setDirection(0); Chronometer c = new Chronometer(); if (timeout > 0) sp.out (out, m, timeout); else sp.out (out, m); ISOMsg resp; try { synchronized (this) { tx++; rxPending++; } for (;;) { resp = (ISOMsg) isp.in (key, timeout); if (!shouldIgnore (resp)) break; } if (resp == null && isp.inp (req) == null) { resp = (ISOMsg) isp.in (key, 10000); } synchronized (this) { if (resp != null) { rx++; lastTxn = System.currentTimeMillis(); }else { rxExpired++; if (m.getDirection() != ISOMsg.OUTGOING) txExpired++; } } } finally { synchronized (this) { rxPending--; } } long elapsed = c.elapsed(); metrics.record("all", elapsed); if (resp != null) metrics.record("ok", elapsed); return resp; }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public ISOMsg request (ISOMsg m, long timeout) throws ISOException { String key = getKey (m); String req = key + ".req"; synchronized (isp) { if (isp.rdp (req) != null) throw new ISOException ("Duplicate key '" + req + "' detected"); isp.out (req, m); } m.setDirection(0); Chronometer c = new Chronometer(); if (timeout > 0) sp.out (out, m, timeout); else sp.out (out, m); ISOMsg resp; try { synchronized (this) { tx++; rxPending++; } for (;;) { resp = (ISOMsg) isp.in (key, timeout); if (!shouldIgnore (resp)) break; } if (resp == null && isp.inp (req) == null) { resp = (ISOMsg) isp.in (key, 10000); } synchronized (this) { if (resp != null) { rx++; lastTxn = System.currentTimeMillis(); }else { rxExpired++; if (m.getDirection() != ISOMsg.OUTGOING) txExpired++; } } } finally { synchronized (this) { rxPending--; } } long elapsed = c.elapsed(); metrics.record("all", elapsed); if (resp != null) metrics.record("ok", elapsed); return resp; } }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public ISOMsg request (ISOMsg m, long timeout) throws ISOException { String key = getKey (m); String req = key + ".req"; synchronized (isp) { if (isp.rdp (req) != null) throw new ISOException ("Duplicate key '" + req + "' detected"); isp.out (req, m); } m.setDirection(0); Chronometer c = new Chronometer(); if (timeout > 0) sp.out (out, m, timeout); else sp.out (out, m); ISOMsg resp; try { synchronized (this) { tx++; rxPending++; } for (;;) { resp = (ISOMsg) isp.in (key, timeout); if (!shouldIgnore (resp)) break; } if (resp == null && isp.inp (req) == null) { resp = (ISOMsg) isp.in (key, 10000); } synchronized (this) { if (resp != null) { rx++; lastTxn = System.currentTimeMillis(); }else { rxExpired++; if (m.getDirection() != ISOMsg.OUTGOING) txExpired++; } } } finally { synchronized (this) { rxPending--; } } long elapsed = c.elapsed(); metrics.record("all", elapsed); if (resp != null) metrics.record("ok", elapsed); return resp; } QMUX(); }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public ISOMsg request (ISOMsg m, long timeout) throws ISOException { String key = getKey (m); String req = key + ".req"; synchronized (isp) { if (isp.rdp (req) != null) throw new ISOException ("Duplicate key '" + req + "' detected"); isp.out (req, m); } m.setDirection(0); Chronometer c = new Chronometer(); if (timeout > 0) sp.out (out, m, timeout); else sp.out (out, m); ISOMsg resp; try { synchronized (this) { tx++; rxPending++; } for (;;) { resp = (ISOMsg) isp.in (key, timeout); if (!shouldIgnore (resp)) break; } if (resp == null && isp.inp (req) == null) { resp = (ISOMsg) isp.in (key, 10000); } synchronized (this) { if (resp != null) { rx++; lastTxn = System.currentTimeMillis(); }else { rxExpired++; if (m.getDirection() != ISOMsg.OUTGOING) txExpired++; } } } finally { synchronized (this) { rxPending--; } } long elapsed = c.elapsed(); metrics.record("all", elapsed); if (resp != null) metrics.record("ok", elapsed); return resp; } QMUX(); void initService(); void startService(); void stopService(); void destroyService(); static MUX getMUX(String name); ISOMsg request(ISOMsg m, long timeout); void request(ISOMsg m, long timeout, ISOResponseListener rl, Object handBack); @Override void notify(Object k, Object value); String getKey(ISOMsg m); @Override Metrics getMetrics(); synchronized void setInQueue(String in); String getInQueue(); synchronized void setOutQueue(String out); String getOutQueue(); Space getSpace(); synchronized void setUnhandledQueue(String unhandled); String getUnhandledQueue(); @SuppressWarnings("unused") String[] getReadyIndicatorNames(); void addISORequestListener(ISORequestListener l); boolean removeISORequestListener(ISORequestListener l); synchronized void resetCounters(); String getCountersAsString(); int getTXCounter(); int getRXCounter(); @Override int getTXExpired(); @Override int getTXPending(); @Override int getRXExpired(); @Override int getRXPending(); @Override int getRXUnhandled(); @Override int getRXForwarded(); long getLastTxnTimestampInMillis(); long getIdleTimeInMillis(); void send(ISOMsg m); boolean isConnected(); void dump(PrintStream p, String indent); }
QMUX extends QBeanSupport implements SpaceListener, MUX, QMUXMBean, Loggeable, MetricsProvider { public ISOMsg request (ISOMsg m, long timeout) throws ISOException { String key = getKey (m); String req = key + ".req"; synchronized (isp) { if (isp.rdp (req) != null) throw new ISOException ("Duplicate key '" + req + "' detected"); isp.out (req, m); } m.setDirection(0); Chronometer c = new Chronometer(); if (timeout > 0) sp.out (out, m, timeout); else sp.out (out, m); ISOMsg resp; try { synchronized (this) { tx++; rxPending++; } for (;;) { resp = (ISOMsg) isp.in (key, timeout); if (!shouldIgnore (resp)) break; } if (resp == null && isp.inp (req) == null) { resp = (ISOMsg) isp.in (key, 10000); } synchronized (this) { if (resp != null) { rx++; lastTxn = System.currentTimeMillis(); }else { rxExpired++; if (m.getDirection() != ISOMsg.OUTGOING) txExpired++; } } } finally { synchronized (this) { rxPending--; } } long elapsed = c.elapsed(); metrics.record("all", elapsed); if (resp != null) metrics.record("ok", elapsed); return resp; } QMUX(); void initService(); void startService(); void stopService(); void destroyService(); static MUX getMUX(String name); ISOMsg request(ISOMsg m, long timeout); void request(ISOMsg m, long timeout, ISOResponseListener rl, Object handBack); @Override void notify(Object k, Object value); String getKey(ISOMsg m); @Override Metrics getMetrics(); synchronized void setInQueue(String in); String getInQueue(); synchronized void setOutQueue(String out); String getOutQueue(); Space getSpace(); synchronized void setUnhandledQueue(String unhandled); String getUnhandledQueue(); @SuppressWarnings("unused") String[] getReadyIndicatorNames(); void addISORequestListener(ISORequestListener l); boolean removeISORequestListener(ISORequestListener l); synchronized void resetCounters(); String getCountersAsString(); int getTXCounter(); int getRXCounter(); @Override int getTXExpired(); @Override int getTXPending(); @Override int getRXExpired(); @Override int getRXPending(); @Override int getRXUnhandled(); @Override int getRXForwarded(); long getLastTxnTimestampInMillis(); long getIdleTimeInMillis(); void send(ISOMsg m); boolean isConnected(); void dump(PrintStream p, String indent);  }