Package org.jboss.jms.client.state

Examples of org.jboss.jms.client.state.ConnectionState


         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);
      }
      finally
      {
View Full Code Here


    */
   protected Connection getConnection(Connection[] conn, int serverId) throws Exception
   {
      for(int i = 0; i < conn.length; i++)
      {
         ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
            getDelegate()).getState());

         if (state.getServerID() == serverId)
         {
            return conn[i];
         }
      }

View Full Code Here

   protected void checkConnectionsDifferentServers(Connection[] conn) throws Exception
   {
      int[] serverID = new int[conn.length];
      for(int i = 0; i < conn.length; i++)
      {
         ConnectionState state = (ConnectionState)(((DelegateSupport)((JBossConnection)conn[i]).
            getDelegate()).getState());
         serverID[i] = state.getServerID();
      }

      for(int i = 0; i < nodeCount; i++)
      {
         for(int j = 0; j < nodeCount; j++)
View Full Code Here

      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);
View Full Code Here

         {
            fail("Did not get expected FAILOVER_COMPLETED event");
         }
      }

      ConnectionState state2 = getConnectionState(conn2);
      ConnectionState state3 = getConnectionState(conn3);

      assertNotSame(state2.getRemotingConnection(), state3.getRemotingConnection());
      assertNotSame(state2.getRemotingConnection().getRemotingClient(),
                    state3.getRemotingConnection().getRemotingClient());

      conn1.close();

      assertNotNull(state2.getRemotingConnection());
      assertNotNull(state2.getRemotingConnection().getRemotingClient().getInvoker());
      assertTrue(state2.getRemotingConnection().getRemotingClient().getInvoker().isConnected());

      conn2.close();

      assertNotNull(state3.getRemotingConnection());
      assertNotNull(state3.getRemotingConnection().getRemotingClient().getInvoker());
      assertTrue(state3.getRemotingConnection().getRemotingClient().getInvoker().isConnected());

      // When I created the testcase this was failing, throwing exceptions. This was basically why
      // I created this testcase
      conn3.close();
   }
View Full Code Here

         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();

         //Now should be able to consume the rest of the messages
View Full Code Here

         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();

         //Now should be able to consume the rest of the messages
View Full Code Here

      }

      SessionState sessionState = (SessionState)producerState.getParent();

      // Generate the message id
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();

      JBossMessage messageToSend;
      boolean foreign = false;

      if (!(m instanceof MessageProxy))
      {
         // it's a foreign message

         foreign = true;

         // JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
         // a message whose implementation is not one of its own.

         // create a matching JBossMessage Type from JMS Type
         if(m instanceof BytesMessage)
         {
            messageToSend = new JBossBytesMessage((BytesMessage)m,0);
         }
         else if(m instanceof MapMessage)
         {
            messageToSend = new JBossMapMessage((MapMessage)m,0);
         }
         else if(m instanceof ObjectMessage)
         {
            messageToSend = new JBossObjectMessage((ObjectMessage)m,0);
         }
         else if(m instanceof StreamMessage)
         {
            messageToSend = new JBossStreamMessage((StreamMessage)m,0);
         }
         else if(m instanceof TextMessage)
         {
            messageToSend = new JBossTextMessage((TextMessage)m,0);
         }
         else
         {
            messageToSend = new JBossMessage(m, 0);
         }

         messageToSend.setJMSMessageID(null);

         //We must set the destination *after* converting from foreign message
         messageToSend.setJMSDestination(destination);
         if(connectionState.getRemotingConnection().isStrictTck())
         {
            m.setJMSDestination(destination);
         }
      }
      else
View Full Code Here

      boolean isCC = ((Boolean)mi.getArguments()[4]).booleanValue();

      // Create the message handler
      SessionState sessionState =
         (SessionState)((DelegateSupport)invocation.getTargetObject()).getState();
      ConnectionState connectionState = (ConnectionState)sessionState.getParent();
      SessionDelegate sessionDelegate = (SessionDelegate)invocation.getTargetObject();
      ConsumerState consumerState = (ConsumerState)((DelegateSupport)consumerDelegate).getState();
      String consumerID = consumerState.getConsumerID();
      int prefetchSize = consumerState.getBufferSize();
      Executor executor = sessionState.getExecutor();
      int maxDeliveries = consumerState.getMaxDeliveries();
      long redeliveryDelay = consumerState.getRedeliveryDelay();
     
      //We need the queue name for recovering any deliveries after failover
      String queueName = null;
      if (consumerState.getSubscriptionName() != null)
      {
         // I have to use the clientID from connectionDelegate instead of connectionState...
         // this is because when a pre configured CF is used we need to get the clientID from
         // server side.
         // This was a condition verified by the TCK and it was fixed as part of
         // http://jira.jboss.com/jira/browse/JBMESSAGING-939
         queueName = MessageQueueNameHelper.
            createSubscriptionName(((ConnectionDelegate)connectionState.getDelegate()).getClientID(),
                                   consumerState.getSubscriptionName());
      }
      else if (consumerState.getDestination().isQueue())
      {
         queueName = consumerState.getDestination().getName();
      }
     
      boolean autoFlowControl = ((Boolean)mi.getArguments()[5]).booleanValue();
     
      ClientConsumer messageHandler =
         new ClientConsumer(isCC, sessionState.getAcknowledgeMode(),
                            sessionDelegate, consumerDelegate, consumerID, queueName,
                            prefetchSize, executor, maxDeliveries, consumerState.isShouldAck(),
                            redeliveryDelay);
     
      sessionState.addCallbackHandler(messageHandler);
     
      CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
      cm.registerHandler(consumerID, messageHandler);
        
      consumerState.setClientConsumer(messageHandler);
     
      if (autoFlowControl)
View Full Code Here

         // First we call close on the ClientConsumer which waits for onMessage invocations
         // to complete and the last delivery to arrive
         consumerState.getClientConsumer().close(lastDeliveryId);

         SessionState sessionState = (SessionState) consumerState.getParent();
         ConnectionState connectionState = (ConnectionState) sessionState.getParent();

         sessionState.removeCallbackHandler(consumerState.getClientConsumer());

         CallbackManager cm = connectionState.getRemotingConnection().getCallbackManager();
         cm.unregisterHandler(consumerState.getConsumerID());

         //And then we cancel any messages still in the message callback handler buffer
         consumerState.getClientConsumer().cancelBuffer();
        
         sessionState.getExecutor().clearClassLoader();

         return l;

      }
      catch (Exception proxiedException)
      {
         ConnectionState connectionState = (ConnectionState) (consumerState.getParent().getParent());
         // if ServerPeer is shutdown or
         // if there is no failover in place... we just close the consumerState as well
         if (proxiedException instanceof MessagingShutdownException ||
                 (connectionState.getFailoverCommandCenter() == null))


         {
            if (!consumerState.getClientConsumer().isClosed())
            {
View Full Code Here

TOP

Related Classes of org.jboss.jms.client.state.ConnectionState

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.