Package org.jboss.jms.client

Examples of org.jboss.jms.client.JBossConnection


      if (!(conn instanceof JBossConnection))
      {
         throw new Exception("Connection not an instance of JBossConnection");
      }
     
      JBossConnection jbconn = (JBossConnection)conn;
     
      DelegateSupport del = (DelegateSupport)jbconn.getDelegate();
     
      ConnectionState state = (ConnectionState)del.getState();
     
      return state.getServerID();
   }
View Full Code Here


  
   public void testWithRealServer() throws Exception
   {
      ConnectionFactory cf = (JBossConnectionFactory)initialContext.lookup("/ConnectionFactory");
     
      JBossConnection conn1 = (JBossConnection)cf.createConnection();
      Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      JBossConnection conn2 = (JBossConnection)cf.createConnection();
      Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
     
      ServerPeer peer = ServerManagement.getServer().getServerPeer();
     
      SimpleConnectionManager cm = (SimpleConnectionManager)peer.getConnectionManager();
     
      //Simulate failure on connection
     
      Map jmsClients = cm.getClients();
      assertEquals(1, jmsClients.size());
     
      //String jvmId = (String)jmsClients.keySet().iterator().next();
     
      Map endpoints = (Map)jmsClients.values().iterator().next();
     
      assertEquals(2, endpoints.size());
     
      Iterator iter = endpoints.entrySet().iterator();
           
      Map.Entry entry = (Map.Entry)iter.next();
     
      String sessId1 = (String)entry.getKey();
     
      //ConnectionEndpoint endpoint1 = (ConnectionEndpoint)entry.getValue();
     
      entry = (Map.Entry)iter.next();
     
      //String sessId2 = (String)entry.getKey();
     
      //ConnectionEndpoint endpoint2 = (ConnectionEndpoint)entry.getValue();
     
      //Simulate failure of connection
     
      cm.handleClientFailure(sessId1, true);
     
      //both connections should be shut
     
      jmsClients = cm.getClients();
      assertEquals(0, jmsClients.size());
     
      try
      {
         sess1.close();
         fail();
      }
      catch (Exception expected)
      {}
     
      try
      {
         sess2.close();
         fail();
      }
      catch (Exception expected)
      {}
     
      try
      {
         conn2.close();
         fail();
      }
      catch (Exception expected)
      {}
     
View Full Code Here

         conn.start();

         for (int i = 0; i < 3; i++)
         {
            JBossConnection connTest = (JBossConnection)
               getConnection(new Connection[]{conn1, conn2, conn3}, i);

            String locator = ((ClientConnectionDelegate) connTest.getDelegate()).
               getRemotingConnection().getRemotingClient().getInvoker().getLocator().getLocatorURI();

            log.info("Server " + i + " has locator=" + locator);

         }
View Full Code Here

     
      try
      {
         xaConn = cf.createXAConnection();
        
         JBossConnection jbConn = (JBossConnection)xaConn;
        
         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
        
         ConnectionState state = (ConnectionState)del.getState();
        
         ResourceManager rm = state.getResourceManager();
        
View Full Code Here

     
      try
      {
         xaConn = cf.createXAConnection();
        
         JBossConnection jbConn = (JBossConnection)xaConn;
        
         ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
        
         ConnectionState state = (ConnectionState)del.getState();
        
         ResourceManager rm = state.getResourceManager();
        
View Full Code Here

      if (!(conn instanceof JBossConnection))
      {
         throw new Exception("Connection not an instance of JBossConnection");
      }
     
      JBossConnection jbconn = (JBossConnection)conn;
     
      DelegateSupport del = (DelegateSupport)jbconn.getDelegate();
     
      ConnectionState state = (ConnectionState)del.getState();
     
      return state.getServerID();
   }
View Full Code Here

      }
      finally
      {
         if (conn != null)
         {
            JBossConnection c = (JBossConnection)conn;
            System.out.println("Server id for connectio is : " + c.getServerID());
            conn.close();
         }
      }
   }
View Full Code Here

   //https://issues.jboss.org/browse/JBMESSAGING-1889
   public void testConnectionConsumerXAFailover() throws Exception
   {
      XAConnection xaConn = null;
      JBossConnection conn = null;
      JBossConnectionConsumer cc = null;
     
      XAConnectionFactory xaCF = (XAConnectionFactory)cf;

      try
      {
         conn = (JBossConnection)createConnectionOnServer(cf, 1);
         xaConn = createXAConnectionOnServer(xaCF, 1);
        
         MockServerSessionPool2 sessionPool = new MockServerSessionPool2(xaConn);

         cc = new JBossConnectionConsumer(conn.getDelegate(),
                                                                  (JBossDestination)queue[1],
                                                                  null,
                                                                  null,
                                                                  sessionPool,
                                                                  5);
        
         conn.start();

         //Send a message
         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer prod = sess.createProducer(queue[1]);
         TextMessage sent1 = sess.createTextMessage("plop1");

         prod.send(sent1);

         sessionPool.waitToFailover();

         // register a failover listener
         SimpleFailoverListener failoverListener = new SimpleFailoverListener();
         ((JBossConnection)conn).registerFailoverListener(failoverListener);
        
         SimpleFailoverListener failoverListener2 = new SimpleFailoverListener();
         ((JBossConnection)xaConn).registerFailoverListener(failoverListener2);

         log.debug("killing node 1 ....");

         ServerManagement.kill(1);

         log.info("########");
         log.info("######## KILLED NODE 1");
         log.info("########");

         // wait for the client-side failover to complete

         while(true)
         {
            FailoverEvent event = failoverListener.getEvent(30000);
            if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
            {
               break;
            }
            if (event == null)
            {
               fail("Did not get expected FAILOVER_COMPLETED event");
            }
         }

         while(true)
         {
            FailoverEvent event = failoverListener2.getEvent(30000);
            if (event != null && FailoverEvent.FAILOVER_COMPLETED == event.getType())
            {
               break;
            }
            if (event == null)
            {
               fail("Did not get expected FAILOVER_COMPLETED event on xaConn");
            }
         }
         // failover complete
         log.info("failover completed");
        
         sessionPool.failoverComplete();
        
         Thread.sleep(5000);
        
         int n = sessionPool.getReceivedMessage();

         //either this should fail or the message is left on the queue. both valid.
         assertTrue(n == 1);
      }
      finally
      {
         if (conn != null)
         {
            conn.close();
         }
         if (xaConn != null)
         {
            xaConn.close();
         }
View Full Code Here

            MessageSucker sucker = (MessageSucker)iter.next();
           
            sucker.suspend();
         }

         final JBossConnection copy = connection;
        
         Callable callable = new Callable() { public Object call()
         {
            try
            {
               copy.close();
            }
            catch (JMSException ignore)
            {             
            }
            return null;
View Full Code Here

    
   public void testWithRealServer() throws Exception
   {
      ConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
     
      JBossConnection conn1 = null;
     
      JBossConnection conn2 = null;
     
     
      try
      {
     
         conn1 = (JBossConnection)cf.createConnection();
         Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         conn2 = (JBossConnection)cf.createConnection();
         Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
         ServerPeer peer = ServerManagement.getServer().getServerPeer();
        
         SimpleConnectionManager cm = (SimpleConnectionManager)peer.getConnectionManager();
        
         //Simulate failure on connection
        
         Map jmsClients = cm.getClients();
         assertEquals(1, jmsClients.size());
        
         Map endpoints = (Map)jmsClients.values().iterator().next();
        
         assertEquals(2, endpoints.size());
        
         Iterator iter = endpoints.entrySet().iterator();
              
         Map.Entry entry = (Map.Entry)iter.next();
        
         String sessId1 = (String)entry.getKey();
         
         entry = (Map.Entry)iter.next();
        
         String sessId2 = (String)entry.getKey();
        
         //Simulate failure of connection
        
         cm.handleClientFailure(sessId1);
 
         jmsClients = cm.getClients();
         assertEquals(1, jmsClients.size());       
        
         cm.handleClientFailure(sessId2);
        
         jmsClients = cm.getClients();
         assertEquals(0, jmsClients.size());  
      }
      finally
      {
         if (conn1 != null)
         {
            conn1.close();
         }
         if (conn2 != null)
         {
            conn2.close();
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.JBossConnection

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.