Example usage for javax.transaction.xa Xid getFormatId

List of usage examples for javax.transaction.xa Xid getFormatId

Introduction

In this page you can find the example usage for javax.transaction.xa Xid getFormatId.

Prototype

int getFormatId();

Source Link

Document

Obtain the format identifier part of the XID.

Usage

From source file:org.wso2.andes.client.XASession_9_1.java

XaStatus commitDtx(Xid xid, boolean onePhase) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();//from   w ww . ja  v a2  s .c o  m

    DtxCommitBody dtxCommitBody = methodRegistry.createDtxCommitBody(xid.getFormatId(),
            xid.getGlobalTransactionId(), xid.getBranchQualifier(), onePhase);

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler
            .syncWrite(dtxCommitBody.generateFrame(_channelId), DtxCommitOkBody.class);

    DtxCommitOkBodyImpl response = (DtxCommitOkBodyImpl) amqMethodEvent.getMethod();

    return XaStatus.valueOf(response.getXaResult());
}

From source file:org.wso2.andes.client.XASession_9_1.java

XaStatus rollbackDtx(Xid xid) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();/*  w ww. j  a  va2s  .  c o m*/

    DtxRollbackBody dtxRollbackBody = methodRegistry.createDtxRollbackBody(xid.getFormatId(),
            xid.getGlobalTransactionId(), xid.getBranchQualifier());

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler
            .syncWrite(dtxRollbackBody.generateFrame(_channelId), DtxRollbackOkBody.class);

    DtxRollbackOkBodyImpl response = (DtxRollbackOkBodyImpl) amqMethodEvent.getMethod();

    return XaStatus.valueOf(response.getXaResult());
}

From source file:org.wso2.andes.client.XASession_9_1.java

/**
 * Sends a dtx.forget frame to broker node and wait for dtx.forget-ok response
 *
 * @param xid distributed transaction ID
 * @return response status//from w  w w .j a v a  2  s .c  om
 * @throws FailoverException if failover process started during communication with server
 * @throws AMQException      if server sends back a error response
 */
public XaStatus forget(Xid xid) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();

    DtxForgetBody dtxForgetBody = methodRegistry.createDtxForgetBody(xid.getFormatId(),
            xid.getGlobalTransactionId(), xid.getBranchQualifier());

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler
            .syncWrite(dtxForgetBody.generateFrame(_channelId), DtxForgetOkBody.class);

    DtxForgetOkBodyImpl response = (DtxForgetOkBodyImpl) amqMethodEvent.getMethod();

    return XaStatus.valueOf(response.getXaResult());
}

From source file:org.wso2.andes.client.XASession_9_1.java

/**
 * Sends a dtx.set-timeout frame to broker node and wait for dtx.set-timeout-ok response
 *
 * @param xid     distribute transction ID
 * @param timeout transaction timeout value to set
 * @return response status// w w  w .  j a v  a  2 s .  c o m
 * @throws FailoverException if failover process started during communication with server
 * @throws AMQException      if server sends back a error response
 */
XaStatus setDtxTimeout(Xid xid, int timeout) throws FailoverException, AMQException, XAException {

    throwErrorIfClosed();

    DtxSetTimeoutBody dtxSetTimeoutBody = methodRegistry.createDtxSetTimeoutBody(xid.getFormatId(),
            xid.getGlobalTransactionId(), xid.getBranchQualifier(), timeout);

    AMQMethodEvent amqMethodEvent = _connection._protocolHandler
            .syncWrite(dtxSetTimeoutBody.generateFrame(_channelId), DtxSetTimeoutOkBody.class);

    DtxSetTimeoutOkBodyImpl response = (DtxSetTimeoutOkBodyImpl) amqMethodEvent.getMethod();

    return XaStatus.valueOf(response.getXaResult());
}