Example usage for javax.transaction.xa XAException toString

List of usage examples for javax.transaction.xa XAException toString

Introduction

In this page you can find the example usage for javax.transaction.xa XAException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.nuxeo.runtime.jtajca.NuxeoContainer.java

protected static TransactionManagerImpl createTransactionManager(TransactionManagerConfiguration config) {
    if (config == null) {
        config = new TransactionManagerConfiguration();
    }//from  w w  w .j  av  a  2  s  .c o m
    try {
        return new TransactionManagerImpl(config.transactionTimeoutSeconds);
    } catch (XAException e) {
        // failed in recovery somewhere
        throw new RuntimeException(e.toString(), e);
    }
}

From source file:org.openadaptor.thirdparty.mq.MqConnection.java

/**
 * Set up connection to MQ/*from w  w  w. j ava  2  s.  co m*/
 * 
 * @param forRead
 */
public void connectToMQ(boolean forRead) {
    log.debug("MqSource starting connection");
    // Following line will suppress all MQ log statements.
    //MQException.log = null;
    // Following suppresses that irritating Reason 2033 log statement that shows up when no message present
    MQException.logExclude(new Integer(MQException.MQRC_NO_MSG_AVAILABLE));
    // initialize MQ now
    MQEnvironment.channel = getChannelName();
    MQEnvironment.hostname = getHostName();
    MQEnvironment.port = getPort();
    if (getUserName() != null)
        MQEnvironment.userID = getUserName();
    if (getPassword() != null)
        MQEnvironment.password = getPassword();
    if (getCcsid() != 0)
        MQEnvironment.CCSID = getCcsid();

    if (isUseLocalTransactions() && isUseXATransactions()) {
        // Both active. Can't allow this.
        throw new ConnectionException("useXATransactions and useLocalTransactions cannot both be true.", this);
    } else if (!(isUseLocalTransactions() || isUseXATransactions())) {
        // Neither transaction mode is active
        try {
            queueManager = new MQQueueManager(getManagerName());
            transactionalResource = null;
        } catch (Exception mqe) {
            throw new ConnectionException("Failed to create MQQueueManager for untransacted session.", mqe,
                    this);
        }
    } else if (isUseLocalTransactions()) {
        // Use Local MQ Transactions
        try {
            queueManager = new MQQueueManager(getManagerName());
            if (isUseLocalTransactions())
                transactionalResource = new MqTransactionalResource(this);
        } catch (Exception mqe) {
            throw new ConnectionException(
                    "Failed to create MQQueueManager for useLocalTransactions non XA session.", mqe, this);
        }
    } else if (isUseXATransactions()) {
        // Use XA Transactions
        try {
            MQXAQueueManager xaQueueManager = new MQXAQueueManager(getManagerName());
            queueManager = xaQueueManager.getQueueManager();
            transactionalResource = xaQueueManager.getXAResource();
        } catch (MQException mqe) {
            throw new ConnectionException("Failed to create MQXAQueueManager with " + mqe.toString(), this);
        } catch (XAException xae) {
            throw new ConnectionException("Failed to create MQXAResource with " + xae.toString(), this);
        }
    }

    try {
        if (forRead) {
            queue = (queueManager.accessQueue(getQueueName(), MQC.MQOO_INPUT_AS_Q_DEF, null, // default q manager 
                    null, // no dynamic q name 
                    null)); // no alternate user id 
        } else {
            int openOptions;
            if (useAllContext) {
                openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_SET_ALL_CONTEXT;
            } else {
                openOptions = MQC.MQOO_OUTPUT;
            }
            queue = (queueManager.accessQueue(getQueueName(), openOptions, null, // default q manager 
                    null, // no dynamic q name 
                    null)); // no alternate user id 
        }

        if (forRead)
            createGetMessageOptions();
        else
            createPutMessageOptions();

    } catch (Exception mqe) {
        throw new RuntimeException("Failed to access queue with " + mqe.toString(), mqe);
    }

    log.debug("MqSource connection successful");
}