Package javax.jms

Examples of javax.jms.ExceptionListener


   {
      ConnectionState state = getConnectionState(invocation);
      state.setJustCreated(false);
     
      MethodInvocation mi = (MethodInvocation)invocation;
      ExceptionListener exceptionListener = (ExceptionListener)mi.getArguments()[0];
      state.getRemotingConnection().getConnectionListener().
         addJMSExceptionListener(exceptionListener);

      return null;
   }
View Full Code Here


   public void handleConnectionException(Throwable throwable, Client client)
   {
      // forward the exception to delegate listeners and JMS ExceptionListeners; synchronize and
      // copy to avoid race conditions

      ExceptionListener jmsExceptionListenerCopy;
      List delegateListenersCopy = new ArrayList();

      synchronized(this)
      {
         jmsExceptionListenerCopy = jmsExceptionListener;

         for(Iterator i = delegateListeners.iterator(); i.hasNext(); )
         {
            delegateListenersCopy.add(i.next());
         }
      }

      for(Iterator i = delegateListenersCopy.iterator(); i.hasNext(); )
      {
         ConnectionListener l = (ConnectionListener)i.next();

         try
         {
            log.debug(this + " forwarding remoting failure \"" + throwable + "\" to " + l);
            l.handleConnectionException(throwable, client);
         }
         catch(Exception e)
         {
            log.warn("Failed to forward " + throwable + " to " + l, e);
         }
      }

      if (jmsExceptionListenerCopy != null)
      {
         JMSException jmsException = null;

         if (throwable instanceof Error)
         {
            final String msg = "Caught Error on underlying remoting connection";
            log.error(this + ": " + msg, throwable);
            jmsException = new JMSException(msg + ": " + throwable.getMessage());
         }
         else if (throwable instanceof Exception)
         {
            Exception e = (Exception)throwable;
            jmsException = new JMSException("Failure on underlying remoting connection");
            jmsException.setLinkedException(e);
         }
         else
         {
            // Some other Throwable subclass
            final String msg = "Caught Throwable on underlying remoting connection";
            log.error(this + ": " + msg, throwable);
            jmsException = new JMSException(msg + ": " + throwable.getMessage());
         }

         jmsExceptionListenerCopy.onException(jmsException);
      }
   }
View Full Code Here

      {
      }
      connection.close();

      connection = cf.createConnection();
      ExceptionListener listener = connection.getExceptionListener();
      try
      {
         connection.setClientID(clientID);
         fail();
      }
View Full Code Here

    */
   public void testExceptionListener() throws Exception
   {
      Connection conn = cf.createConnection();

      ExceptionListener listener1 = new MyExceptionListener();

      conn.setExceptionListener(listener1);

      ExceptionListener listener2 = conn.getExceptionListener();

      assertNotNull(listener2);

      assertEquals(listener1, listener2);

View Full Code Here

    private void prepareQueues() throws Exception
    {
        // Create a connection
        Connection connection = _connFac.createConnection();
        connection.start();
        connection.setExceptionListener(new ExceptionListener()
        {
            public void onException(JMSException e)
            {
                e.printStackTrace();
            }
View Full Code Here

    {

        // Create a connection
        TopicConnection connection = _connFac.createTopicConnection();
        connection.start();
        connection.setExceptionListener(new ExceptionListener()
        {
            public void onException(JMSException e)
            {
                e.printStackTrace();
            }
View Full Code Here

    private void prepareDurableSubscriptionWithoutSelector() throws Exception
    {
        // Create a connection
        TopicConnection connection = _connFac.createTopicConnection();
        connection.start();
        connection.setExceptionListener(new ExceptionListener()
        {
            public void onException(JMSException e)
            {
                e.printStackTrace();
            }
View Full Code Here

    }

    private void deliverJMSExceptionToExceptionListenerOrLog(final JMSException je, final Throwable cause)
    {
        // deliver the exception if there is a listener
        ExceptionListener exceptionListener = getExceptionListenerNoCheck();
        if (exceptionListener != null)
        {
            exceptionListener.onException(je);
        }
        else
        {
            _logger.error("Throwable Received but no listener set: " + cause);
        }
View Full Code Here

                    {
                    }
                    try
                    {
                        final Error error = end == null ? null : end.getError();
                        final ExceptionListener exceptionListener = _connection.getExceptionListener();
                        if(exceptionListener != null)
                        {
                            if(error != null)
                            {
                                SessionException se = new SessionException(
                                        error.getDescription(),
                                        error.getCondition().getValue().toString());

                                exceptionListener.onException(se);
                            }
                            else
                            {
                                exceptionListener.onException(new SessionException("Session remotely closed"));
                            }
                        }
                    }
                    catch (JMSException e)
                    {
View Full Code Here

                        {

                            consumers.remove();
                            try
                            {
                                ExceptionListener expListener = _connection.getExceptionListener();
                                if (expListener != null)
                                    expListener.onException(e);
                                consumer.close();
                            }
                            catch (JMSException e1)
                            {
                            }
View Full Code Here

TOP

Related Classes of javax.jms.ExceptionListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.