Package javax.transaction

Examples of javax.transaction.Transaction


    @Override
    public Object intercept(final EasyBeansInvocationContext invocationContext) throws Exception {
        logger.debug("Calling Not Supported TX interceptor");

        // Get current transaction
        Transaction transaction;
        try {
            transaction = getTransactionManager().getTransaction();
        } catch (SystemException se) {
            throw new EJBException("Cannot get the current transaction on transaction manager.", se);
        }

        logger.debug("Transaction found = {0}", transaction);

        /*
         * If a client calls with a transaction context, the container suspends
         * the association of the transaction context with the current thread
         * before invoking the enterprise bean?s business method.
         */

        Transaction suspendedTransaction = null;
        if (transaction != null) {
            try {
                logger.debug("Suspending transaction {0}", transaction);
                suspendedTransaction = getTransactionManager().suspend();
            } catch (SystemException se) {
View Full Code Here


    *
    * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-410.
    */
   public void testSendNoGlobalTransaction() throws Exception
   {
      Transaction suspended = null;

      try
      {
         ServerManagement.deployQueue("MyQueue");

View Full Code Here

    * was initally enroled in a global transaction.
    */
   public void testSendNoGlobalTransaction2() throws Exception
   {

      Transaction suspended = TransactionManagerLocator.getInstance().locate().suspend();

      try
      {

         ConnectionFactory mcf =
View Full Code Here

         p.send(m);
         conn.close();

         // make sure there's no active JTA transaction

         Transaction suspended = TransactionManagerLocator.getInstance().locate().suspend();

         try
         {
            // using a JCA wrapper
View Full Code Here

            //The connection will probably be closed so this may well throw an exception
         }
      }
      if (tm.getTransaction() != null)
      {
         Transaction tx = tm.suspend();
         if (tx != null)
            log.warn("Transaction still associated with thread " + tx + " at status " + TxUtils.getStatusAsString(tx.getStatus()));
      }   
     
      if (suspendedTx != null)
      {
         tm.resume(suspendedTx);
View Full Code Here

         for (int i = 0; i < 100; i++)
         {
           
            tm.begin();
                    
            Transaction tx = tm.getTransaction();
           
            tx.enlistResource(res);
           
            tx.enlistResource(dummy);
           
            assertEquals(1, rm.size());
           
            tx.delistResource(res, XAResource.TMSUCCESS);
           
            tx.delistResource(dummy, XAResource.TMSUCCESS);
           
            tm.commit();
         }                 
        
         assertEquals(1, rm.size());
View Full Code Here

        
         XAResource res = xaSession.getXAResource();
        
         tm.begin();
        
         Transaction tx = tm.getTransaction();
         tx.enlistResource(res);
        
         //This should cause the work done previously to be converted into work done in the xa transaction
         //this is what an MDB does
         //There is a difficulty in transactional delivery with an MDB.
         //The message is received from the destination and then sent to the mdb container so
         //it can call onMessage.
         //For transactional delivery the receipt of the message should be in a transaction but by the time
         //the mdb container is invoked the message has already been received it is too late - the message
         //has already been received and passed on (see page 199 (chapter 5 JMS and Transactions, section "Application Server Integration"
         //of Mark Little's book Java Transaction processing
         //for a discussion of how different app serves deal with this)
         //The way jboss messaging (and jboss mq) deals with this is to convert any work done
         //prior to when the xasession is enlisted in the tx, into work done in the xa tx
        
         tx.delistResource(res, XAResource.TMSUCCESS);
        
         //Now rollback the tx - this should cause redelivery of the two messages
         tx.rollback();
        
         rm1 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm1);
        
View Full Code Here

        
         XAResource res = xaSession.getXAResource();
        
         tm.begin();
        
         Transaction tx = tm.getTransaction();
         tx.enlistResource(res);
        
         tx.delistResource(res, XAResource.TMSUCCESS);
        
         //Then we do a commit
         tm.commit();
                             
         //Then we receive the messages outside the tx
        
         TextMessage rm1 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm1);
        
         assertEquals("message1", rm1.getText());
        
         TextMessage rm2 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm2);
        
         assertEquals("message2", rm2.getText());
        
         Message rm3 = cons.receive(1000);
        
         assertNull(rm3);
        
         //And enlist again - this should convert the work done in the local tx
         //into the global branch
        
         tx = tm.getTransaction();
        
         tm.begin();
        
         tx = tm.getTransaction();
         tx.enlistResource(res);
        
         tx.delistResource(res, XAResource.TMSUCCESS);        
              
         //Now rollback the tx - this should cause redelivery of the two messages
         tx.rollback();
        
         rm1 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm1);
        
View Full Code Here

        
         XAResource res = xaSession.getXAResource();
        
         tm.begin();
        
         Transaction tx = tm.getTransaction();
         tx.enlistResource(res);
         tx.delistResource(res, XAResource.TMSUCCESS);
        
         //Then we do a rollback
         tm.rollback();                
        
         //Then we receive the messages outside the global tx
        
         TextMessage rm1 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm1);
        
         assertEquals("message1", rm1.getText());
        
         TextMessage rm2 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm2);
        
         assertEquals("message2", rm2.getText());
        
         Message rm3 = cons.receive(1000);
        
         assertNull(rm3);
        
         tm.begin();
        
         //And enlist again - the work should then be converted into the global tx branch
        
         tx = tm.getTransaction();
        
         tx.enlistResource(res);
        
         tx.delistResource(res, XAResource.TMSUCCESS);
              
         //Now rollback the tx - this should cause redelivery of the two messages
         tx.rollback();
        
         rm1 = (TextMessage)cons.receive(1000);
        
         assertNotNull(rm1);
        
View Full Code Here

         XASession sess = conn.createXASession();
         XAResource res = sess.getXAResource();
        
         XAResource res2 = new DummyXAResource();
        
         Transaction tx = tm.getTransaction();
         tx.enlistResource(res);
         tx.enlistResource(res2);
        
         MessageProducer prod = sess.createProducer(queue);
         prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
         Message m = sess.createTextMessage("XATest1");
         prod.send(queue, m);
         m = sess.createTextMessage("XATest2");
         prod.send(queue, m);
        
         tx.delistResource(res, XAResource.TMSUCCESS);
         tx.delistResource(res2, XAResource.TMSUCCESS);
        
         tm.commit();
        
         conn2 = cf.createConnection();
         conn2.start();
View Full Code Here

TOP

Related Classes of javax.transaction.Transaction

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.