Package org.jboss.jms.client.delegate

Examples of org.jboss.jms.client.delegate.ClientConnectionDelegate


         ServerManagement.invoke(on, "start", new Object[0], new String[0]);

         ConnectionFactory cf = (ConnectionFactory)ic[0].lookup("/ClusteredTestChangeRateConfigSettingsFactory");
         c = cf.createConnection();
        
         ClientConnectionDelegate del1 = (ClientConnectionDelegate)((JBossConnection)c).getDelegate();
        
         ConnectionState state1 = (ConnectionState)del1.getState();
        
         long maxRetry = state1.getMaxRetryChangeRate();
        
         assertEquals(10, maxRetry);
        
View Full Code Here


         ServerManagement.invoke(on, "start", new Object[0], new String[0]);

         ConnectionFactory cf = (ConnectionFactory)ic[0].lookup("/ClusteredTestChangeRateConfigDefaultsFactory");
         c = cf.createConnection();
        
         ClientConnectionDelegate del1 = (ClientConnectionDelegate)((JBossConnection)c).getDelegate();
        
         ConnectionState state1 = (ConnectionState)del1.getState();
        
         long maxRetry = state1.getMaxRetryChangeRate();
        
         assertEquals(0, maxRetry);
        
View Full Code Here

         ServerManagement.invoke(on, "start", new Object[0], new String[0]);

         ConnectionFactory cf = (ConnectionFactory)ic[0].lookup("/ClusteredTestMinTimeoutProcessTimeConfigSettingsFactory");
         c = cf.createConnection();
        
         ClientConnectionDelegate del1 = (ClientConnectionDelegate)((JBossConnection)c).getDelegate();
        
         ConnectionState state1 = (ConnectionState)del1.getState();
        
         long minTime = state1.getMinTimeoutProcessTime();
        
         assertEquals(100, minTime);
      }
View Full Code Here

         ServerManagement.invoke(on, "start", new Object[0], new String[0]);

         ConnectionFactory cf = (ConnectionFactory)ic[0].lookup("/ClusteredTestMinTimeoutProcessTimeConfigSettingsFactory");
         c = cf.createConnection();
        
         ClientConnectionDelegate del1 = (ClientConnectionDelegate)((JBossConnection)c).getDelegate();
        
         ConnectionState state1 = (ConnectionState)del1.getState();
        
         long minTime = state1.getMinTimeoutProcessTime();
        
         assertEquals(100, minTime);
      }
View Full Code Here

         ServerManagement.invoke(on, "start", new Object[0], new String[0]);

         ConnectionFactory cf = (ConnectionFactory)ic[0].lookup("/ClusteredTestChangeRateConfigDefaultsFactory");
         c = cf.createConnection();
        
         ClientConnectionDelegate del1 = (ClientConnectionDelegate)((JBossConnection)c).getDelegate();
        
         ConnectionState state1 = (ConnectionState)del1.getState();
        
         long minTime = state1.getMinTimeoutProcessTime();
        
         assertEquals(300, minTime);
      }
View Full Code Here

         JBossConnection jbc = (JBossConnection)conn;
        
         SimpleFailoverListener failoverListener = new SimpleFailoverListener();
         ((JBossConnection)conn).registerFailoverListener(failoverListener);

         ClientConnectionDelegate del = (ClientConnectionDelegate)jbc.getDelegate();

         ConnectionState state = (ConnectionState)del.getState();

         int initialServerID = state.getServerID();

         assertEquals(1, initialServerID);

         Session sess = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);

         MessageProducer prod = sess.createProducer(queue[1]);

         MessageConsumer cons = sess.createConsumer(queue[1]);

         final int NUM_MESSAGES = 100;

         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = sess.createTextMessage("message:" + i);

            prod.send(tm);
         }

         conn.start();

         //Now consume half of the messages but don't ack them these will end up in
         //client side toAck list

         for (int i = 0; i < NUM_MESSAGES / 2; i++)
         {
            TextMessage tm = (TextMessage)cons.receive(10000);

            assertNotNull(tm);

            assertEquals("message:" + i, tm.getText());
         }

         //So now, messages should be in queue[1] on server 1
         //So we now kill server 1
         //Which should cause transparent failover of connection conn onto server 2

         ServerManagement.kill(1);

         // 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");
            }
         }


         state = (ConnectionState)del.getState();

         int finalServerID = state.getServerID();

         conn.start();
View Full Code Here

         SimpleFailoverListener failoverListener = new SimpleFailoverListener();
         ((JBossConnection)conn).registerFailoverListener(failoverListener);

         JBossConnection jbc = (JBossConnection)conn;

         ClientConnectionDelegate del = (ClientConnectionDelegate)jbc.getDelegate();

         ConnectionState state = (ConnectionState)del.getState();

         int initialServerID = state.getServerID();

         assertEquals(1, initialServerID);

         Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);

         MessageProducer prod = sess.createProducer(queue[1]);

         MessageConsumer cons = sess.createConsumer(queue[1]);

         final int NUM_MESSAGES = 100;

         for (int i = 0; i < NUM_MESSAGES; i++)
         {
            TextMessage tm = sess.createTextMessage("message:" + i);

            prod.send(tm);
         }

         sess.commit();

         conn.start();

         //Now consume half of the messages but don't commit them these will end up in
         //client side resource manager

         for (int i = 0; i < NUM_MESSAGES / 2; i++)
         {
            TextMessage tm = (TextMessage)cons.receive(2000);

            assertNotNull(tm);

            assertEquals("message:" + i, tm.getText());
         }

         //So now, messages should be in queue[1] on server 1
         //So we now kill server 1
         //Which should cause transparent failover of connection conn onto server 2
        
         ServerManagement.kill(1);

         //       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");
            }
         }
         state = (ConnectionState)del.getState();

         int finalServerID = state.getServerID();

         conn.start();
View Full Code Here

         Object txID = sessionState.getCurrentTxId();

         producer.send(session.createTextMessage("Hello again before failover"));

         ClientConnectionDelegate delegate = (ClientConnectionDelegate) conn.getDelegate();

         JMSRemotingConnection originalRemoting = delegate.getRemotingConnection();

         ServerManagement.kill(1);

         // 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");
            }
         }
         // if failover happened, this object was replaced
         assertNotSame(originalRemoting, delegate.getRemotingConnection());

         message = session.createTextMessage("Hello After");
         producer.send(message);

         assertEquals(txID, sessionState.getCurrentTxId());
View Full Code Here

   public Object handleCreateConnectionDelegate(Invocation inv) throws Throwable
   {
      CreateConnectionResult res = (CreateConnectionResult)inv.invokeNext();

      ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)res.getDelegate();

      if (connectionDelegate != null && connectionDelegate.getState() == null)
      {
         // no state set yet, initialize and configure it

         if(trace) { log.trace(connectionDelegate + " not configured, configuring ..."); }

         int serverID = connectionDelegate.getServerID();
         Version versionToUse = connectionDelegate.getVersionToUse();
         JMSRemotingConnection remotingConnection = connectionDelegate.getRemotingConnection();

         if (versionToUse == null)
         {
            throw new IllegalStateException("Connection version is null");
         }

         ConnectionState connectionState =
            new ConnectionState(serverID, connectionDelegate,
                                remotingConnection, versionToUse,
                                connectionDelegate.isEnableOrderingGroup(), connectionDelegate.getDefaultOrderingGroupName());

         remotingConnection.getConnectionListener().setConnectionState(connectionState);
         remotingConnection.getConnectionListener().start();
         
         connectionDelegate.setState(connectionState);
      }

      return res;
   }
View Full Code Here

      try
      {
         if (failedNodeID == -1)
         {
            // Just a standard createConnection
            ClientConnectionDelegate cd =
               createConnectionDelegateInternal(username, password, failedNodeID,
                                                remotingSessionID, clientVMID,
                                                versionToUse,
                                                callbackHandler);
            return new CreateConnectionResult(cd);
         }
         else
         {
            log.trace(this + " received client-side failover request. Creating failover "+
               "connection to replace connection to failed node " + failedNodeID);

            // Wait for server side failover to complete
            int failoverNodeID = serverPeer.getFailoverWaiter().waitForFailover(failedNodeID);
           
            if (failoverNodeID == -1 || failoverNodeID != serverPeer.getServerPeerID())
            {
               log.trace(this + " realized that we are on the wrong node or no failover has occured");
               return new CreateConnectionResult(failoverNodeID);
            }
            else
            {
               log.trace(this + " received notification that server-side failover completed, " +
                  "creating connection delegate ...");
               ClientConnectionDelegate cd =
                  createConnectionDelegateInternal(username, password, failedNodeID,
                                                   remotingSessionID, clientVMID,
                                                   versionToUse,
                                                   callbackHandler);
               return new CreateConnectionResult(cd);
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.delegate.ClientConnectionDelegate

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.