Package javax.transaction.xa

Examples of javax.transaction.xa.XAException


    public void start(Xid xid, int flag) throws XAException {
        if (flag == XAResource.TMNOFLAGS) {
            // first time in this transaction
            if (this.xid != null) {
                throw new XAException("already enlisted");
            }
            this.xid = xid;
            try {
                localTransaction.begin();
            } catch (ResourceException e) {
                throw (XAException) new XAException("could not start local tx").initCause(e);
            }
        } else if (flag == XAResource.TMRESUME) {
            if (xid != this.xid) {
                throw new XAException("attempting to resume in different transaction");
            }
        } else {
            throw new XAException("unknown state");
        }
     }
View Full Code Here


    // Implementation of javax.transaction.xa.XAResource

    public void commit(Xid xid, boolean flag) throws XAException {
        if (this.xid == null || !this.xid.equals(xid)) {
            throw new XAException();
        }
        try {
            localTransaction.commit();
        } catch (ResourceException e) {
            throw (XAException)new XAException().initCause(e);
         } finally {
            this.xid = null;
        }

    }
View Full Code Here

        return new Xid[0];
    }

    public void rollback(Xid xid) throws XAException {
        if (this.xid == null || !this.xid.equals(xid)) {
            throw new XAException();
        }
        try {
            localTransaction.rollback();
        } catch (ResourceException e) {
            throw (XAException)new XAException().initCause(e);
        } finally {
            this.xid = null;
        }
    }
View Full Code Here

    public void start(Xid xid, int flag) throws XAException {
        if (flag == XAResource.TMNOFLAGS) {
            // first time in this transaction
            if (this.xid != null) {
                throw new XAException("already enlisted");
            }
            this.xid = xid;
            try {
                localTransaction.begin();
            } catch (ResourceException e) {
                throw (XAException) new XAException("could not start local tx").initCause(e);
            }
        } else if (flag == XAResource.TMRESUME) {
            if (xid != this.xid) {
                throw new XAException("attempting to resume in different transaction");
            }
        } else {
            throw new XAException("unknown state");
        }
    }
View Full Code Here

        }
    }

    public void end(Xid xid, int flag) throws XAException {
        if (xid != this.xid) {
            throw new XAException();
        }
        //we could keep track of if the flag is TMSUCCESS...
    }
View Full Code Here

            // if we retry and its not there the assume that it was committed
            if (xaRetry && response.getResponseCode() == XAException.XAER_NOTA)
            {
               return;
            }
            throw new XAException(response.getResponseCode());
         }
      }
      catch (HornetQException e)
      {
         ClientSessionImpl.log.warn("failover occured during commit throwing XAException.XA_RETRY");

         // Unblocked on failover
         xaRetry = true;
         // Any error on commit -> RETRY
         // We can't rollback a Prepared TX for definition
         throw new XAException(XAException.XA_RETRY);
      }
   }
View Full Code Here

   {
      checkXA();

      if (rollbackOnly)
      {
         throw new XAException(XAException.XA_RBOTHER);
      }

      try
      {
         Packet packet;

         if (flags == XAResource.TMSUSPEND)
         {
            packet = new PacketImpl(PacketImpl.SESS_XA_SUSPEND);
         }
         else if (flags == XAResource.TMSUCCESS)
         {
            packet = new SessionXAEndMessage(xid, false);
         }
         else if (flags == XAResource.TMFAIL)
         {
            packet = new SessionXAEndMessage(xid, true);
         }
         else
         {
            throw new XAException(XAException.XAER_INVAL);
         }

         flushAcks();

         SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);

         if (response.isError())
         {
            throw new XAException(response.getResponseCode());
         }
      }
      catch (HornetQException e)
      {
         ClientSessionImpl.log.error("Caught jmsexecptione ", e);
         // This should never occur
         throw new XAException(XAException.XAER_RMERR);
      }
   }
View Full Code Here

      {
         SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(new SessionXAForgetMessage(xid));

         if (response.isError())
         {
            throw new XAException(response.getResponseCode());
         }
      }
      catch (HornetQException e)
      {
         // This should never occur
         throw new XAException(XAException.XAER_RMERR);
      }
   }
View Full Code Here

         return response.getTimeoutSeconds();
      }
      catch (HornetQException e)
      {
         // This should never occur
         throw new XAException(XAException.XAER_RMERR);
      }
   }
View Full Code Here

   {
      checkXA();

      if (rollbackOnly)
      {
         throw new XAException(XAException.XA_RBOTHER);
      }

      // Note - don't need to flush acks since the previous end would have
      // done this

      SessionXAPrepareMessage packet = new SessionXAPrepareMessage(xid);

      try
      {
         SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);

         if (response.isError())
         {
            throw new XAException(response.getResponseCode());
         }
         else
         {
            xaRetry = false;
            return response.getResponseCode();
         }
      }
      catch (HornetQException e)
      {
         if (e.getCode() == HornetQException.UNBLOCKED)
         {
            // Unblocked on failover
            try
            {
               log.warn("failover occurred during prepare re-trying");
               SessionXAResponseMessage response = (SessionXAResponseMessage)channel.sendBlocking(packet);

               if (response.isError())
               {
                  throw new XAException(response.getResponseCode());
               }
               else
               {
                  xaRetry = false;
                  return response.getResponseCode();
               }
            }
            catch (HornetQException e1)
            {
               // ignore and rollback
            }
            log.warn("failover occurred during prepare rolling back");
            try
            {
               rollback(false);
            }
            catch (HornetQException e2)
            {
               throw new XAException(XAException.XAER_RMERR);
            }

            ClientSessionImpl.log.warn(e.getMessage(), e);

            throw new XAException(XAException.XA_RBOTHER);
         }

         ClientSessionImpl.log.warn(e.getMessage(), e);

         // This should never occur
         throw new XAException(XAException.XAER_RMERR);
      }
   }
View Full Code Here

TOP

Related Classes of javax.transaction.xa.XAException

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.