Examples of SessionState


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

      return null
   }
  
   public Object handleCommit(Invocation invocation) throws Throwable
   {
      SessionState state = getState(invocation);
     
      synchronized (state)
      {  
         if (!state.isTransacted())
         {
            throw new IllegalStateException("Cannot commit a non-transacted session");
         }
  
         if (state.isXA())
         {
            throw new TransactionInProgressException("Cannot call commit on an XA session");
         }
  
         ConnectionState connState = (ConnectionState)state.getParent();
         ConnectionDelegate conn = (ConnectionDelegate)connState.getDelegate();
    
         try
         {
            connState.getResourceManager().commitLocal((LocalTx)state.getCurrentTxId(), conn);
         }
         finally
         {
            //Start new local tx
            Object xid = connState.getResourceManager().createLocalTx();
  
            state.setCurrentTxId(xid);
         }
        
         //TODO on commit we don't want to ACK any messages that have exceeded the max delivery count OR
  
         return null;
View Full Code Here

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

      }
   }

   public Object handleRollback(Invocation invocation) throws Throwable
   {
      SessionState state = getState(invocation);
     
      synchronized (state)
      {
         if (!state.isTransacted())
         {
            throw new IllegalStateException("Cannot rollback a non-transacted session");
         }
  
         if (state.isXA())
         {
            throw new TransactionInProgressException("Cannot call rollback on an XA session");
         }
        
         ConnectionState connState = (ConnectionState)state.getParent();
         ResourceManager rm = connState.getResourceManager();
         try
         {
            rm.rollbackLocal((LocalTx)state.getCurrentTxId());
         }
         finally
         {
            // start new local tx
            Object xid = rm.createLocalTx();
            state.setCurrentTxId(xid);
         }
  
         return null;
      }
   }
View Full Code Here

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

      }
   }
  
   public Object handleSend(Invocation invocation) throws Throwable
   {
      SessionState state = getState(invocation);
      Object txID = state.getCurrentTxId();

      // If there is no GlobalTransaction we run it as local transacted
      // as discussed at http://www.jboss.com/index.html?module=bb&op=viewtopic&t=98577
      // http://jira.jboss.org/jira/browse/JBMESSAGING-946
      // and
      // http://jira.jboss.org/jira/browse/JBMESSAGING-410
      if ((!state.isXA() && state.isTransacted()) || (state.isXA() && !(txID instanceof LocalTx)))
      {
         // the session is non-XA and transacted, or XA and enrolled in a global transaction, so
         // we add the message to a transaction instead of sending it now. An XA session that has
         // not been enrolled in a global transaction behaves as a non-transacted session.

         ConnectionState connState = (ConnectionState)state.getParent();
         MethodInvocation mi = (MethodInvocation)invocation;
         Message m = (Message)mi.getArguments()[0];

         if (trace) { log.trace("sending message " + m + " transactionally, queueing on resource manager txID=" + txID + " sessionID= " + state.getSessionID()); }

         connState.getResourceManager().addMessage(txID, state.getSessionID(), (JBossMessage)m);

         // ... and we don't invoke any further interceptors in the stack
         return null;
      }
View Full Code Here

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

      try
      {
         JBossSession session = (JBossSession) conn.createSession(true, Session.SESSION_TRANSACTED);
         ClientSessionDelegate clientSessionDelegate = (ClientSessionDelegate) session.getDelegate();
         SessionState sessionState = (SessionState) clientSessionDelegate.getState();

         MessageConsumer consumerHA = session.createDurableSubscriber((Topic) destination, "T1");

         MessageProducer producer = session.createProducer(destination);
         Message message = session.createTextMessage("Hello Before");
         producer.send(message);
         session.commit();

         receiveMessage("consumerHA", consumerHA, true, false);

         session.commit();
         //if (true) return;

         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());
         session.commit();

         receiveMessage("consumerHA", consumerHA, true, false);
         receiveMessage("consumerHA", consumerHA, true, false);
View Full Code Here

Examples of org.jsmpp.extra.SessionState

     * @param activityName is the activity name.
     * @throws IOException if the session not receivable.
     */
    protected void ensureReceivable(String activityName) throws IOException {
        // TODO uudashr: do we have to use another exception for this checking?
        SessionState currentState = getSessionState();
        if (!currentState.isReceivable()) {
            throw new IOException("Cannot " + activityName + " while in state " + currentState);
        }
    }
View Full Code Here

Examples of org.virtualbox_4_2.SessionState

   @Test
   public void testEnsureMachineisLaunchedAndSessionIsUnlocked() {
      ISession cloneMachineSession = machineController.ensureMachineIsLaunched(clonedMachine.getName());
      assertTrue(cloneMachineSession.getState() == SessionState.Unlocked);
      cloneMachineSession = machineController.ensureMachineHasPowerDown(clonedMachine.getName());
      SessionState state = cloneMachineSession.getState();
      assertEquals(SessionState.Unlocked, state);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.