0 Replies Latest reply on Nov 2, 2006 10:54 AM by mveitas

    Should stopping a destination cause a connection exception

    mveitas

      Should stopping a destination via the JMX console, cause an exception to be registered with the client connection? If not, how can I get the client to register an exception via the ExceptionListener interface?

      Properties p = new Properties();
       p.put( "java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
       p.put( "java.naming.provider.url", "jnp://localhost:1099" );
       p.put( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
      
       try
       {
       Context context = new InitialContext( p );
       ConnectionFactory connectionFactory = ( ConnectionFactory ) context.lookup( "ConnectionFactory" );
       Destination destination = ( Destination ) context.lookup( "queue/B" );
       Connection connection = connectionFactory.createConnection();
       connection.setExceptionListener( new ExceptionListener()
       {
       public void onException( JMSException jmsException )
       {
       System.out.println( "EXCEPTION: " + jmsException );
       }
       } );
       Session session = connection.createSession( false, Session.CLIENT_ACKNOWLEDGE );
       MessageConsumer consumer = session.createConsumer( destination );
       consumer.setMessageListener( new MessageListener()
       {
       public void onMessage( Message message )
       {
       System.out.println( "Message: " + message );
       }
       } );
      
       connection.start();
       }
       catch( Exception e )
       {
       e.printStackTrace();
       }