Examples of XAResource


Examples of javax.transaction.xa.XAResource

   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
   public boolean wipeOutTxsInDoubt(Set<RecoveredXid> xidsToRecover)
   {
      log.info("wipe out in-doubt txs");

      XAResource xares = null;
      try
      {
         xares = getNewXAResource();
        
         if (xares == null)
            return false;

         Xid[] txInDoubt = null;
         try
         {              
            txInDoubt = xares.recover(XAResource.TMSTARTRSCAN);
         }
         catch (XAException e)
         {
            log.error("Cannot start recovering on xares", e);

            try
            {
               xares.recover(XAResource.TMENDRSCAN);
            }
            catch (Exception e1)
            {
            }

            return false;
         }

         if (txInDoubt == null || txInDoubt.length == 0)
            return true;

         log.info("There are " + txInDoubt.length + " xids in doubt");

         for (int k=0; k < txInDoubt.length; k++)
         {
            RecoveredXid xid = convertToRecoveredXid(txInDoubt[k]);
            if (xidsToRecover == null || xidsToRecover.contains(xid))
            {
               try
               {
                  log.info("rollbacking of Xid " + xid);
                  xares.rollback(txInDoubt[k]);
               }
               catch (Exception e)
               {
                  log.error("Error in rollback of Xid " + txInDoubt[k], e);
               }
            }
         }

         try
         {
            if (xares != null)
               xares.recover(XAResource.TMENDRSCAN);
         }
         catch (XAException e)
         {
            log.error("Cannot finish recovering on xares", e);
         }
View Full Code Here

Examples of javax.transaction.xa.XAResource

   @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
   public Set<RecoveredXid> checkXidsInDoubt()
   {
      Set<RecoveredXid> xids = new HashSet<RecoveredXid>();

      XAResource xares = null;
      try
      {              
         xares = getNewXAResource();

         try
         {
            Xid[] xidsInDoubt = xares.recover(XAResource.TMSTARTRSCAN);

            if (xidsInDoubt != null)
            {
               log.info("There are " + xidsInDoubt.length + " xids in doubt");

               for (int k=0; k < xidsInDoubt.length; k++)
                  xids.add(convertToRecoveredXid(xidsInDoubt[k]));
            }
         }
         catch (XAException e)
         {
            log.error("Cannot start recover scan on xares", e);
            throw new EJBException("Cannot start recover scan on xares: " + e.getMessage());
         }
         finally
         {
            try
            {
               if (xares != null)
                  xares.recover(XAResource.TMENDRSCAN);
            }
            catch (XAException e)
            {
               log.error("Cannot finish recover scan on xares", e);
            }
View Full Code Here

Examples of javax.transaction.xa.XAResource

         TopicPublisher publisher = session.createPublisher(topic);
         Message message = session.createTextMessage();

         // Add the xa resource to xid1
         MyXid xid1 = new MyXid();
         XAResource resource = xaSession.getXAResource();
         resource.start(xid1, XAResource.TMNOFLAGS);

         // Do some work
         publisher.publish(message);

         // Suspend the transaction
         resource.end(xid1, XAResource.TMSUSPEND);

         // Add the xa resource to xid2
         MyXid xid2 = new MyXid();
         resource.start(xid2, XAResource.TMNOFLAGS);

         // Do some work in the new transaction
         publisher.publish(message);

         // Commit the first transaction and end the branch
         resource.end(xid1, XAResource.TMSUCCESS);
         resource.commit(xid1, true);

         // Do some more work in the new transaction
         publisher.publish(message);

         // Commit the second transaction and end the branch
         resource.end(xid2, XAResource.TMSUCCESS);
         resource.commit(xid2, true);
      }
      catch(Exception e)
      {
         e.printStackTrace();
         throw e;
View Full Code Here

Examples of javax.transaction.xa.XAResource

         // Set up
         XATopicSession xaSession = connection.createXATopicSession();

         // Add the xa resource to xid1
         MyXid xid1 = new MyXid();
         XAResource resource = xaSession.getXAResource();
         resource.start(xid1, XAResource.TMNOFLAGS);

         TopicSession session = xaSession.getTopicSession();
         TopicSubscriber subscriber = session.createSubscriber(topic);
         connection.start();
         TopicPublisher publisher = session.createPublisher(topic);
         Message message = session.createTextMessage();

         // Publish a message using "AutoAcknowledge"
         publisher.publish(message);

         resource.end(xid1, XAResource.TMSUCCESS);
         resource.prepare(xid1);
         // JBossMessaging only sends the message when a commit is done, while JBossMQ would send messages to consumers on the same session,
         // doing something differently on the transaction isolation.
         // Because of that this commit is necessary to complete this testcase.
         resource.commit(xid1, false);

         xid1 = new MyXid();
         resource.start(xid1, XAResource.TMNOFLAGS);

         // Receive the message
         message = subscriber.receive(1000);
         if (message == null)
            fail("No message?");

         // Prepare the transaction
         resource.end(xid1, XAResource.TMSUCCESS);
         resource.prepare(xid1);
        
         // Rollback
         resource.rollback(xid1);

         xid1 = new MyXid();
         resource.start(xid1, XAResource.TMNOFLAGS);
         // Receive the message using "AutoAcknowledge"
         message = subscriber.receiveNoWait();
         if (message == null)
            fail("No message after rollback?");
         resource.end(xid1, XAResource.TMSUCCESS);
         resource.commit(xid1, true);

      }
      finally
      {
         connection.close();
View Full Code Here

Examples of javax.transaction.xa.XAResource

      }

      // Get the endpoint
      MessageEndpointFactory endpointFactory = activation
            .getMessageEndpointFactory();
      XAResource xaResource = null;

      if (activation.isDeliveryTransacted() && xaSession != null)
         xaResource = xaSession.getXAResource();

      endpoint = endpointFactory.createEndpoint(xaResource);
View Full Code Here

Examples of javax.transaction.xa.XAResource

            if (trace)
               log.trace(JmsServerSession.this + " using tx=" + trans);

            if (xaSession != null)
            {
               XAResource res = xaSession.getXAResource();

               if (!trans.enlistResource(res))
               {
                  throw new JMSException("could not enlist resource");
               }
View Full Code Here

Examples of javax.transaction.xa.XAResource

   }

   public ConnectionListener createConnectionListener(ManagedConnection mc, Object context)
      throws ResourceException
   {
      XAResource xaResource = null;
     
      if (localTransactions)
      {
         xaResource = new LocalXAResource(log);
   
         if (xaResourceTimeout != 0)
            log.debug("XAResource transaction timeout cannot be set for local transactions: " + getJndiName());
      }
     
      else
      {
        
         if(wrapXAResource)
         {
            String eisProductName = null;
            String eisProductVersion = null;

            try
            {
               if (mc.getMetaData() != null)
               {
                  eisProductName = mc.getMetaData().getEISProductName();
                  eisProductVersion = mc.getMetaData().getEISProductVersion();
               }
            }
            catch (ResourceException re)
            {
               // Ignore
            }

            if (eisProductName == null)
               eisProductName = getJndiName();

            if (eisProductVersion == null)
               eisProductVersion = getJndiName();

            if (trace)
               log.trace("Generating XAResourceWrapper for TxConnectionManager" + this);

            xaResource = new XAResourceWrapperImpl(mc.getXAResource(), padXid, isSameRMOverrideValue, eisProductName, eisProductVersion);
         }
        
         else
         {
            log.trace("Not wrapping XAResource.");
            xaResource = mc.getXAResource();
         }
                               
         if (xaResourceTimeout != 0)
         {
            try
            {
               if (xaResource.setTransactionTimeout(xaResourceTimeout) == false)
                  log.debug("XAResource does not support transaction timeout configuration: " + getJndiName());
            }
            catch (XAException e)
            {
               throw new JBossResourceException("Unable to set XAResource transaction timeout: " + getJndiName(), e);
View Full Code Here

Examples of javax.transaction.xa.XAResource

         {
            if (trace)
               log.trace("Enlisting resource " + TxConnectionEventListener.this);
            try
            {
               XAResource resource = getXAResource();
               if (false == currentTx.enlistResource(resource))
                  enlistError = FAILED_TO_ENLIST;
            }
            catch (Throwable t)
            {
View Full Code Here

Examples of javax.transaction.xa.XAResource

            // Check if we got a valid Subject instance; requirement for recovery
            if (subject != null)
            {
               ManagedConnection mc = open(subject);
               XAResource xaResource = null;

               try
               {
                  xaResource = mc.getXAResource();
               }
View Full Code Here

Examples of javax.transaction.xa.XAResource

     * @param tx
     * @param options
     */
    private void enlistResource(ManagedConnection mconn, Transaction tx, Map options)
    {
        XAResource res = mconn.getXAResource();
        if (res != null)
        {
            // Enlist the connection resource if has enlistable resource
            boolean enlistInLocalTM = true;
            if (options != null && options.get("resource-type") != null &&
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.