@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 onException(JMSException ex) { ExceptionListener listener = this.exceptionListener; if (listener != null) { listener.onException(JmsExceptionSupport.create(ex)); } }
/** * @param ex */ public void onException(JMSException ex) { ExceptionListener l = this.exceptionListener; if (l != null) { l.onException(StompJmsExceptionSupport.create(ex)); } }
protected void handleException(Throwable e) { running = false; JMSException wrapped; if (e instanceof JMSException) { wrapped = (JMSException) e; } else { wrapped = new JMSException("Wrapped exception. " + e.getMessage()); wrapped.addSuppressed(e); } this.exceptionListener.onException(wrapped); }
@Override public void onException(JMSException exception) { // capture exceptions, and schedule a refresh of the ReplyTo destination log.warn("Exception inside the DMLC for Temporary ReplyTo Queue for destination " + endpoint.getDestinationName() + ", refreshing ReplyTo destination", exception); destResolver.scheduleRefresh(); // serve as a proxy for any exception listener the user may have set explicitly if (delegate != null) { delegate.onException(exception); } }
@Override public void onException(JMSException exception) { if (isReconnectOnException()) { close(); } if (parentExceptionListener != null) { parentExceptionListener.onException(exception); } }