Package org.jboss.jms.client.delegate

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


   public void testUpdateConnectionFactoryRaceCondition() throws Exception
   {
      // This connection needs to be opened, as we need the callback to update CF from this conn
      Connection conn = createConnectionOnServer(cf, 0);
      JBossConnectionFactory jbcf = (JBossConnectionFactory) cf;
      ClientClusteredConnectionFactoryDelegate cfDelegate =
         (ClientClusteredConnectionFactoryDelegate) jbcf.getDelegate();
      assertEquals(2, cfDelegate.getDelegates().length);

      Connection conn1 = cf.createConnection();

      Connection conn2 = cf.createConnection();

      assertEquals(1, getServerId(conn1));
     
      assertEquals(0, getServerId(conn2));

      ConnectionState state = this.getConnectionState(conn1);

      // Disable Leasing for Failover
      state.getRemotingConnection().removeConnectionListener();

      ServerManagement.kill(1);

      Thread.sleep(20000);

      // This will force Failover from Valve to kick in
      conn1.createSession(true, Session.SESSION_TRANSACTED);

      // first part of the test, verifies if the CF was updated
      assertEquals(1, cfDelegate.getDelegates().length);

      assertEquals(0, getServerId(conn1));
     
      conn.close();
      conn1.close();
View Full Code Here


    * Test that connections created using a clustered connection factory are created round robin on
    * different servers
    */
   public void testRoundRobinConnectionCreation() throws Exception
   {
      ClientClusteredConnectionFactoryDelegate delegate =
         (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();

      assertEquals(3, delegate.getDelegates().length);

      ClientConnectionFactoryDelegate cf1 = delegate.getDelegates()[0];

      ClientConnectionFactoryDelegate cf2 = delegate.getDelegates()[1];

      ClientConnectionFactoryDelegate cf3 = delegate.getDelegates()[2];

      assertEquals(0, cf1.getServerID());

      assertEquals(1, cf2.getServerID());

View Full Code Here

   /** testcase for http://jira.jboss.com/jira/browse/JBMESSAGING-1038 */
   public void testHopping() throws Exception
   {

      JBossConnectionFactory localcf = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
      ClientClusteredConnectionFactoryDelegate cfdelegate = (ClientClusteredConnectionFactoryDelegate)localcf.getDelegate();

      ((ClientClusteredConnectionFactoryDelegate)cf.getDelegate()).closeCallback(false);

      // After this, the CF won't get any callbacks
      cfdelegate.closeCallback(false);

      Connection conn = createConnectionOnServer(localcf, 1);

      try
      {

         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageProducer producer = sess.createProducer(queue[1]);

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

         conn.start();

         producer.send(sess.createTextMessage("sent before kill"));
         TextMessage msg = (TextMessage)consumer.receive(2000);

         assertNotNull(msg);
         assertEquals("sent before kill", msg.getText());

         ServerManagement.kill(2);
         ServerManagement.kill(1);

         // We need to guarantee we still have the old failover map (before the topology change for the test to be valid)
         assertEquals(3, cfdelegate.getDelegates().length);

         log.info("Sending Message");
         producer.send(sess.createTextMessage("sent after kill"));
         msg = (TextMessage) consumer.receive(2000);

View Full Code Here

                        //We still replicate non clustered connection factories since the ClusterPullConnectionFactory
                        //is non clustered but needs to be available across the cluster
                     }
                     else
                     {
                        ClientClusteredConnectionFactoryDelegate del = (ClientClusteredConnectionFactoryDelegate)cfd;

                        Map updatedReplicantMap = replicator.get(key);

                        List newDels = sortDelegatesOnServerID(updatedReplicantMap.values());

                        ClientConnectionFactoryDelegate[] delArr =
                           (ClientConnectionFactoryDelegate[])newDels.
                              toArray(new ClientConnectionFactoryDelegate[newDels.size()]);

                        Map failoverMap = serverPeer.getPostOfficeInstance().getFailoverMap();

                        del.setDelegates(delArr);
                        del.setFailoverMap(failoverMap);

                        ServerConnectionFactoryEndpoint endpoint =
                           (ServerConnectionFactoryEndpoint)endpoints.get(uniqueName);

                        if (endpoint == null)
View Full Code Here

      LoadBalancingPolicy lbp = loadBalancingFactory.createLoadBalancingPolicy(delegates);

      endpoint.updateTopology(delegates, failoverMap);

      return new ClientClusteredConnectionFactoryDelegate(uniqueName, delegates, failoverMap, lbp, supportsFailover, enableOrderingGroup, defaultOrderingGroupName);
   }
View Full Code Here

                        //We still replicate non clustered connection factories since the ClusterPullConnectionFactory
                        //is non clustered but needs to be available across the cluster
                     }
                     else
                     {
                        ClientClusteredConnectionFactoryDelegate del = (ClientClusteredConnectionFactoryDelegate)cfd;

                        Map updatedReplicantMap = replicator.get(key);

                        List newDels = sortDelegatesOnServerID(updatedReplicantMap.values());

                        ClientConnectionFactoryDelegate[] delArr =
                           (ClientConnectionFactoryDelegate[])newDels.
                              toArray(new ClientConnectionFactoryDelegate[newDels.size()]);

                        Map failoverMap = serverPeer.getPostOfficeInstance().getFailoverMap();

                        del.setDelegates(delArr);
                        del.setFailoverMap(failoverMap);

                        ServerConnectionFactoryEndpoint endpoint =
                           (ServerConnectionFactoryEndpoint)endpoints.get(uniqueName);

                        if (endpoint == null)
View Full Code Here

   {
      if (trace) { log.trace(this + " handling " + message); }

      ConnectionFactoryUpdate viewChange = (ConnectionFactoryUpdate)message;

      ClientClusteredConnectionFactoryDelegate delegate = delegateRef.get();

      if (delegate!=null)
      {
         delegate.updateFailoverInfo(viewChange.getTopology().getDelegates(),
                                           viewChange.getTopology().getFailoverMap());
      }
   }
View Full Code Here

   class CallbackConnectionListener implements ConnectionListener
   {

      public void handleConnectionException(Throwable throwable, Client client)
      {
         ClientClusteredConnectionFactoryDelegate delegate = delegateRef.get();

         if (delegate!=null)
         {
            delegate.establishCallback(true);
         }

         //remotingConnection.removePlainConnectionListener(this);
      }
View Full Code Here

   public void testRestartServer() throws Exception
   {
      JBossConnectionFactory cf2 = (JBossConnectionFactory) ic[1].lookup("/ConnectionFactory");

      ClientClusteredConnectionFactoryDelegate clusterCF = (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();
      ClientConnectionFactoryDelegate delegates[] = clusterCF.getDelegates();
      clusterCF.closeCallback(false);

      ServerManagement.kill(1);

      //Restart the server on the same place
      ServiceAttributeOverrides attr = new ServiceAttributeOverrides();
View Full Code Here

   {
      Connection conn = createConnectionOnServer(cf, 0);

      JBossConnectionFactory jbcf = (JBossConnectionFactory)cf;

      ClientClusteredConnectionFactoryDelegate cfDelegate =
         (ClientClusteredConnectionFactoryDelegate)jbcf.getDelegate();

      assertEquals(2, cfDelegate.getDelegates().length);

      Connection conn1 = cf.createConnection();

      assertEquals(1, getServerId(conn1));

      ServerManagement.kill(1);

      log.info("sleeping 5 secs ...");
      Thread.sleep(5000);

      // first part of the test, verifies if the CF was updated
      assertEquals(1, cfDelegate.getDelegates().length);
      conn.close();

      log.info("sleeping 5 secs ...");
      Thread.sleep(5000);

      // Second part, verifies a possible race condition on failoverMap and handleFilover
      assertEquals(0, getServerId(conn1));
    
      //restart
      ServerManagement.start(1, "all", false);
     
      Thread.sleep(5000);
     
      assertEquals(2, cfDelegate.getDelegates().length);
     
      conn1.close();
     
      ServerManagement.stop(1);
   }
View Full Code Here

TOP

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

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.