Package javax.jms

Examples of javax.jms.ExceptionListener


      {
         final LinkedQueue buffer = new LinkedQueue();
         conn = createConnectionOnServer(theCF, 1);
         conn.start();

         conn.setExceptionListener(new ExceptionListener()
         {
            public void onException(JMSException e)
            {
               try
               {
View Full Code Here


   public void handleConnectionException(Throwable throwable, Client client)
   {
      // 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 = 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

   {
      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

   {
      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

      {
      }
      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

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

               if (exceptionListener != null)
               {
                  final JMSException je = new JMSException(me.toString());

                  je.initCause(me);

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

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.