Package org.jboss.jms.client.state

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


      return null;
   }
  
   public Object handleGetConnectionMetaData(Invocation invocation) throws Throwable
   {
      ConnectionState currentState = getConnectionState(invocation);
      currentState.setJustCreated(false);
     
      if (connMetaData == null)
      {
         ClientConnectionDelegate delegate = (ClientConnectionDelegate)invocation.getTargetObject();
         connMetaData = new JBossConnectionMetaData(((ConnectionState)delegate.getState()).getVersionToUse());
View Full Code Here


      return connMetaData;
   }
  
   public Object handleStart(Invocation invocation) throws Throwable
   {
      ConnectionState currentState = getConnectionState(invocation);
      currentState.setStarted(true);
      return invocation.invokeNext();
   }
View Full Code Here

      return invocation.invokeNext();
   }
  
   public Object handleStop(Invocation invocation) throws Throwable
   {
      ConnectionState currentState = getConnectionState(invocation);
      currentState.setStarted(false);
      return invocation.invokeNext();
   }
View Full Code Here

      return invocation.invokeNext();
   }
  
   public Object handleCreateSessionDelegate(Invocation invocation) throws Throwable
   {
      ConnectionState currentState = getConnectionState(invocation);
      currentState.setJustCreated(false);
      return invocation.invokeNext();
   }
View Full Code Here

  
   public Object handleClose(Invocation invocation) throws Throwable
   {
      Object ret = invocation.invokeNext();
     
      ConnectionState state = getConnectionState(invocation);

      JMSRemotingConnection remotingConnection = state.getRemotingConnection();

      // remove the consolidated remoting connection listener

      ConsolidatedRemotingConnectionListener l = remotingConnection.removeConnectionListener();
      if (l != null)
      {
         l.clear();
      }

      // Finished with the connection - we need to shutdown callback server
      remotingConnection.stop();
      
      // Remove reference to message ID generator
      MessageIdGeneratorFactory.instance.checkInGenerator(state.getServerID());
     
      // And to resource manager
      ResourceManagerFactory.instance.checkInResourceManager(state.getServerID());

      return ret;
   }
View Full Code Here

      return ret;
   }

   public Object  handleRegisterFailoverListener(Invocation invocation) throws Throwable
   {
      ConnectionState state = getConnectionState(invocation);

      MethodInvocation mi = (MethodInvocation)invocation;
      FailoverListener listener = (FailoverListener)mi.getArguments()[0];

      state.getFailoverCommandCenter().registerFailoverListener(listener);

      return null;
   }
View Full Code Here

      return null;
   }

   public Object handleUnregisterFailoverListener(Invocation invocation) throws Throwable
   {
      ConnectionState state = getConnectionState(invocation);

      MethodInvocation mi = (MethodInvocation)invocation;
      FailoverListener listener = (FailoverListener)mi.getArguments()[0];

      boolean result = state.getFailoverCommandCenter().unregisterFailoverListener(listener);

      return new Boolean(result);
   }
View Full Code Here

      // this is a bit counterintuitve, as we're not copying from new delegate, but modifying its
      // state based on the old state. It makes sense, since in the end the state makes it to the
      // server

      ConnectionState thisState = (ConnectionState)state;

      if (thisState.getClientID() != null)
      {
         newDelegate.setClientID(thisState.getClientID());
      }

      // synchronize (recursively) the client-side state

      state.synchronizeWith(newDelegate.getState());

      // synchronize the delegates

      remotingConnection = newDelegate.getRemotingConnection();
      versionToUse = newDelegate.getVersionToUse();

      // There is one RM per server, so we need to merge the rms if necessary
      ResourceManagerFactory.instance.handleFailover(serverID, newDelegate.getServerID());

      client = thisState.getRemotingConnection().getRemotingClient();

      serverID = newDelegate.getServerID();
   }
View Full Code Here

      //Sanity check
      if (state.isXA())
      {
         if (trace) { log.trace("Session is XA"); }
        
         ConnectionState connState = (ConnectionState)state.getParent();
        
         ResourceManager rm = connState.getResourceManager();
        
         // An XASession should never be closed if there is prepared ack work that has not yet been
         // committed or rolled back. Imagine if messages had been consumed in the session, and
         // prepared but not committed. Then the connection was explicitly closed causing the
         // session to close. Closing the session causes any outstanding delivered but unacked
         // messages to be cancelled to the server which means they would be available for other
         // consumers to consume. If another consumer then consumes them, then recover() is called
         // and the original transaction is committed, then this means the same message has been
         // delivered twice which breaks the once and only once delivery guarantee.
        
         if (rm.checkForAcksInSession(state.getSessionID()))
         {
            throw new IllegalStateException(
               "Attempt to close an XASession when there are still uncommitted acknowledgements!");
         }       
      }
           
      int ackMode = state.getAcknowledgeMode();
 
      //We need to either ack (for auto_ack) or cancel (for client_ack)
      //any deliveries - this is because the message listener might have closed
      //before on message had finished executing
     
      if (ackMode == Session.AUTO_ACKNOWLEDGE)
      {
         //Acknowledge or cancel any outstanding auto ack
        
         DeliveryInfo remainingAutoAck = state.getAutoAckInfo();
        
         if (remainingAutoAck != null)
         {
            if (trace) { log.trace(this + " handleClosing(). Found remaining auto ack. Will ack " + remainingAutoAck); }
           
            try
            {
               ackDelivery(del, remainingAutoAck);
              
               if (trace) { log.trace(this + " acked it"); }              
            }
            finally
            {                       
               state.setAutoAckInfo(null);
            }
         }
      }
      else if (ackMode == Session.DUPS_OK_ACKNOWLEDGE)
      {
         //Ack any remaining deliveries
                         
         if (!state.getClientAckList().isEmpty())
         {              
            try
            {
               del.acknowledgeDeliveries(state.getClientAckList());
            }
            finally
            {           
               state.getClientAckList().clear();
              
               state.setAutoAckInfo(null);
            }
         }
      }
      else if (ackMode == Session.CLIENT_ACKNOWLEDGE)
      {
         // Cancel any oustanding deliveries
         // We cancel any client ack or transactional, we do this explicitly so we can pass the
         // updated delivery count information from client to server. We could just do this on the
         // server but we would lose delivery count info.
                 
         // CLIENT_ACKNOWLEDGE cannot be used with MDBs (i.e. no connection consumer)
         // so is always safe to cancel on this session                 
        
         cancelDeliveries(del, state.getClientAckList());
        
         state.getClientAckList().clear();
      }
      else if (state.isTransacted() && !state.isXA())
      {
         //We need to explicitly cancel any deliveries back to the server
         //from the resource manager, otherwise delivery count won't be updated
        
         ConnectionState connState = (ConnectionState)state.getParent();
        
         ResourceManager rm = connState.getResourceManager();
        
         List dels = rm.getDeliveriesForSession(state.getSessionID());
        
         cancelDeliveries(del, dels);       
      }
View Full Code Here

   {     
      Object res = invocation.invokeNext();
     
      SessionState state = getState(invocation);

      ConnectionState connState = (ConnectionState)state.getParent();

      Object xid = state.getCurrentTxId();

      if (xid != null)
      {
         //Remove transaction from the resource manager
         connState.getResourceManager().removeTx(xid);
      }

      // We must explicitly shutdown the executor

      state.getExecutor().shutdownNow();
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.