[jboss-user] [IronJacamar] - Re: JCA Adapter & Recovery

Ant Kutschera do-not-reply at jboss.com
Sun Jul 7 11:02:17 EDT 2013


Ant Kutschera [https://community.jboss.org/people/maxant] created the discussion

"Re: JCA Adapter & Recovery"

To view the discussion, visit: https://community.jboss.org/message/826755#826755

--------------------------------------------------------------
Hi Tom,

It isn't being called.  Why could that be?

The class is shown below - altho the recover method is returning null at the moment, it isn't printing the log, or if I use the debugger, it doesn't stop in that method. 

-----------------------

package ch.maxant.jca_demo.sapresourceadapter;


import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.jboss.security.Base64Utils;


public class XASAPResource
  implements XAResource, Serializable
{
  private final Logger log = Logger.getLogger(getClass().getName());
  private SAPManagedConnection conn;
  private int timeout = 300;


  public XASAPResource(SAPManagedConnection conn) {
    this.conn = conn;
  }


  public void commit(Xid xid, boolean onePhase)
    throws XAException
  {
    this.log.log(Level.FINE, "COMMIT " + onePhase + "/" + gtid(xid));
    try
    {
      this.conn.webService().confirm(gtid(xid));


      this.conn.cleanup();
    }
    catch (Exception e)
    {
      this.log.log(Level.SEVERE, "Failed to CONFIRM", e);
      throw new XAException(-3);
    }
  }


  public void end(Xid xid, int flags)
    throws XAException
  {
    String s = "-";
    if (flags == 33554432)
      s = "TMSUSPEND";
    else if (flags == 536870912)
      s = "TMFAIL";
    else if (flags == 67108864) {
      s = "TMSUCCESS";
    }


    this.log.log(Level.INFO, "END flags=" + s + "(" + flags + ")" + "/" + gtid(xid));
  }


  public void forget(Xid xid)
    throws XAException
  {
    this.log.log(Level.INFO, "FORGET " + gtid(xid));
  }


  public int getTransactionTimeout()
    throws XAException
  {
    return this.timeout;
  }


  public boolean isSameRM(XAResource xares)
    throws XAException
  {
    this.log.log(Level.INFO, "isSameRM " + xares);


    return equals(xares);
  }


  public int prepare(Xid xid)
    throws XAException
  {
    this.log.log(Level.INFO, "PREPARE " + gtid(xid));


    if (!this.conn.wasTrySuccessful().booleanValue()) {
      throw new XAException(100);
    }


    return 0;
  }


  public Xid[] recover(int arg0)
    throws XAException
  {
    this.log.log(Level.INFO, "RECOVER " + arg0);
    return null;
  }


  public void rollback(Xid xid)
    throws XAException
  {
    this.log.log(Level.INFO, "ROLLBACK " + gtid(xid));
    try
    {
      this.conn.webService().cancel(gtid(xid));


      this.conn.cleanup();
    }
    catch (Exception e)
    {
      throw new XAException(-3);
    }
  }


  public boolean setTransactionTimeout(int timeout)
    throws XAException
  {
    this.log.log(Level.INFO, "SET TRANSACTION TIMEOUT " + timeout);
    this.timeout = timeout;


    return true;
  }


  public void start(Xid xid, int arg1)
    throws XAException
  {
    this.log.log(Level.INFO, "START " + arg1 + "/" + gtid(xid));


    this.conn.setCurrentTxId(gtid(xid));
  }


  private String gtid(Xid xid)
  {
    return Base64Utils.tob64(xid.getGlobalTransactionId());
  }
}
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/826755#826755]

Start a new discussion in IronJacamar at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2098]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130707/45e22fe9/attachment-0001.html 


More information about the jboss-user mailing list