@Override public void onException(JMSException ex) { for (ExceptionListener listener : this.delegates) { listener.onException(ex); } }
@Override public void onException(JMSException ex) { // Iterate over temporary copy in order to avoid ConcurrentModificationException, // since listener invocations may in turn trigger registration of listeners... Set<ExceptionListener> copy; synchronized (connectionMonitor) { copy = new LinkedHashSet<>(this.delegates); } for (ExceptionListener listener : copy) { listener.onException(ex); } } }
@Override public void run() { exceptionListener.onException(je); } }).start();
@Override public void run() { ActiveMQConnection.this.exceptionListener.onException(e); } });
/** * Invoke the registered JMS ExceptionListener, if any. * @param ex the exception that arose during JMS processing * @see #setExceptionListener */ protected void invokeExceptionListener(JMSException ex) { ExceptionListener exceptionListener = getExceptionListener(); if (exceptionListener != null) { exceptionListener.onException(ex); } }
@Override public void onException(JMSException exception) { Span span = tracer.currentSpan(); if (span == null) { delegate.onException(exception); return; } try (SpanInScope ws = tracer.withSpanInScope(span)) { delegate.onException(exception); } finally { span.error(exception); } } }
@Test public void testWithConnectionFactoryAndReconnectOnException() throws JMSException { ConnectionFactory cf = mock(ConnectionFactory.class); TestConnection con = new TestConnection(); given(cf.createConnection()).willReturn(con); SingleConnectionFactory scf = new SingleConnectionFactory(cf); scf.setReconnectOnException(true); Connection con1 = scf.createConnection(); assertNull(con1.getExceptionListener()); con1.start(); con.getExceptionListener().onException(new JMSException("")); Connection con2 = scf.createConnection(); con2.start(); scf.destroy(); // should trigger actual close assertEquals(2, con.getStartCount()); assertEquals(2, con.getCloseCount()); }
@Test public void testWithConnectionFactoryAndExceptionListenerAndReconnectOnException() throws JMSException { ConnectionFactory cf = mock(ConnectionFactory.class); TestConnection con = new TestConnection(); given(cf.createConnection()).willReturn(con); TestExceptionListener listener = new TestExceptionListener(); SingleConnectionFactory scf = new SingleConnectionFactory(cf); scf.setExceptionListener(listener); scf.setReconnectOnException(true); Connection con1 = scf.createConnection(); assertSame(listener, con1.getExceptionListener()); con1.start(); con.getExceptionListener().onException(new JMSException("")); Connection con2 = scf.createConnection(); con2.start(); scf.destroy(); // should trigger actual close assertEquals(2, con.getStartCount()); assertEquals(2, con.getCloseCount()); assertEquals(1, listener.getCount()); }
con2.setExceptionListener(listener2); assertSame(listener2, con2.getExceptionListener()); con.getExceptionListener().onException(new JMSException("")); con2.close(); con.getExceptionListener().onException(new JMSException("")); con1.close(); con.getExceptionListener().onException(new JMSException(""));
@Test public void testWithConnectionFactoryAndLocalExceptionListenerWithReconnect() throws JMSException { ConnectionFactory cf = mock(ConnectionFactory.class); TestConnection con = new TestConnection(); given(cf.createConnection()).willReturn(con); TestExceptionListener listener0 = new TestExceptionListener(); TestExceptionListener listener1 = new TestExceptionListener(); TestExceptionListener listener2 = new TestExceptionListener(); SingleConnectionFactory scf = new SingleConnectionFactory(cf); scf.setReconnectOnException(true); scf.setExceptionListener(listener0); Connection con1 = scf.createConnection(); con1.setExceptionListener(listener1); assertSame(listener1, con1.getExceptionListener()); con1.start(); Connection con2 = scf.createConnection(); con2.setExceptionListener(listener2); assertSame(listener2, con2.getExceptionListener()); con.getExceptionListener().onException(new JMSException("")); con2.close(); con1.getMetaData(); con.getExceptionListener().onException(new JMSException("")); con1.close(); scf.destroy(); // should trigger actual close assertEquals(2, con.getStartCount()); assertEquals(2, con.getCloseCount()); assertEquals(2, listener0.getCount()); assertEquals(2, listener1.getCount()); assertEquals(1, listener2.getCount()); }
verify(exceptionListener).onException(theException);
@Override public void run() { exceptionListener.onException(je); } }).start();
@Override public void run() { ActiveMQConnection.this.exceptionListener.onException(e); } });
@Override public void run() { exceptionListener.onException(je); } }).start();
@Override public void run() { ActiveMQConnection.this.exceptionListener.onException(e); } });
public void run() { exceptionListener.onException(je); } }).start();
/** * Calls the <code>ExceptionListener</code> * using the specified exception. * @param exception the exception */ public void callExceptionListener(JMSException exception) { if(listener != null && exception != null) { listener.onException(exception); } }
@Override public void run() { ActiveMQConnection.this.exceptionListener.onException(e); } });
@Override public void run() { exceptionListener.onException(je); } }).start();
public void onException(JMSException ex) { for (ExceptionListener listener : this.delegates) { listener.onException(ex); } }