Package javax.jms

Examples of javax.jms.ExceptionListener


            @Override
            public void run()
            {
                try
                {
                    final ExceptionListener exceptionListener = _session.getConnection().getExceptionListener();

                    if(exceptionListener != null)
                    {
                        final Error receiverError = _receiver.getError();

                        MessageConsumerException mce = new MessageConsumerException(
                                receiverError.getDescription(),
                                receiverError.getCondition().getValue().toString(),
                                _destination.getAddress());

                        exceptionListener.onException(mce);
                    }
                }
                catch (JMSException e)
                {
View Full Code Here


       
        //QPID-2081: use a latch to sync on exception causing connection close, to work
        //around the connection close race during tearDown() causing sporadic failures
        _exceptionReceived = new CountDownLatch(1);

        connection.setExceptionListener(new ExceptionListener()
        {
            public void onException(JMSException e)
            {
                _exceptionReceived.countDown();
            }
View Full Code Here

        doTest();
    }

    public void testWithExceptionListener() throws Exception
    {
        _connection.setExceptionListener(new ExceptionListener()
            {
                public void onException(JMSException jmsException)
                {
                    _log.warn("onException - " + jmsException.getMessage());
                }
View Full Code Here

        // Monitor the connection for an exception being thrown
        // this should be a DisconnectionException but it is not this tests
        // job to valiate that. Only use the exception as a synchronisation
        // to check the log file for the Close message
        final CountDownLatch exceptionReceived = new CountDownLatch(1);
        connection.setExceptionListener(new ExceptionListener()
        {
            public void onException(JMSException e)
            {
                //Failover being attempted.
                exceptionReceived.countDown();
View Full Code Here

         String[] remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals(1, remoteAddresses.length);
         String remoteAddress = remoteAddresses[0];

         final CountDownLatch exceptionLatch = new CountDownLatch(1);
         connection.setExceptionListener(new ExceptionListener()
         {
            public void onException(final JMSException e)
            {
               exceptionLatch.countDown();
            }
View Full Code Here

         Assert.assertEquals(1, server.getConnectionCount());
         String[] remoteAddresses = control.listRemoteAddresses();
         Assert.assertEquals(1, remoteAddresses.length);

         final CountDownLatch exceptionLatch = new CountDownLatch(1);
         connection.setExceptionListener(new ExceptionListener()
         {
            public void onException(final JMSException e)
            {
               exceptionLatch.countDown();
            }
View Full Code Here

      }
           
      // forward the exception to delegate listener and JMS ExceptionListeners; synchronize
      // to avoid race conditions

      ExceptionListener jmsExceptionListenerCopy;
 
      ConnectionFailureListener remotingListenerCopy;

      synchronized(this)
      {
         jmsExceptionListenerCopy = jmsExceptionListener;

         remotingListenerCopy = remotingListener;
      }
     
      boolean forwardToJMSListener = true;

      if (remotingListenerCopy != null)
      {
         try
         {
            log.trace(this + " forwarding remoting failure \"" + throwable + "\" to " + remotingListenerCopy);
           
            //We only forward to the JMS listener if failover did not successfully handle the exception
            //If failover handled the exception transparently then there is effectively no problem
            //with the logical connection that the client needs to be aware of
            forwardToJMSListener = !remotingListenerCopy.handleConnectionException(throwable, client);
         }
         catch(Exception e)
         {
            log.warn("Failed to forward " + throwable + " to " + remotingListenerCopy, e);
         }
      }
     
      if (forwardToJMSListener && 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 = JMSTestCase.cf.createConnection();
      ExceptionListener listener = connection.getExceptionListener();
      try
      {
         connection.setClientID(clientID);
         ProxyAssertSupport.fail();
      }
View Full Code Here

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

      ExceptionListener listener1 = new MyExceptionListener();

      conn.setExceptionListener(listener1);

      ExceptionListener listener2 = conn.getExceptionListener();

      ProxyAssertSupport.assertNotNull(listener2);

      ProxyAssertSupport.assertEquals(listener1, listener2);

View Full Code Here

         if (conn != null)
         {
            try
            {
               final ExceptionListener exceptionListener = conn.getExceptionListener();

               if (exceptionListener != null)
               {
                  final JMSException je = new JMSException(me.toString(), failedOver?EXCEPTION_FAILOVER: EXCEPTION_DISCONNECT);

                  je.initCause(me);

                  new Thread(new Runnable()
                  {
                     public void run()
                     {
                        exceptionListener.onException(je);
                     }
                  }).start();
               }
            }
            catch (JMSException e)
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.