本文整理汇总了Java中org.apache.activemq.command.TransactionId.isXATransaction方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionId.isXATransaction方法的具体用法?Java TransactionId.isXATransaction怎么用?Java TransactionId.isXATransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.command.TransactionId
的用法示例。
在下文中一共展示了TransactionId.isXATransaction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTransaction
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
public Transaction getTransaction(ConnectionContext context, TransactionId xid, boolean mightBePrepared) throws JMSException, XAException {
Map transactionMap = null;
synchronized (xaTransactions) {
transactionMap = xid.isXATransaction() ? xaTransactions : context.getTransactions();
}
Transaction transaction = (Transaction)transactionMap.get(xid);
if (transaction != null) {
return transaction;
}
if (xid.isXATransaction()) {
XAException e = new XAException("Transaction '" + xid + "' has not been started.");
e.errorCode = XAException.XAER_NOTA;
throw e;
} else {
throw new JMSException("Transaction '" + xid + "' has not been started.");
}
}
示例2: rollback
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
/**
* @throws IOException
* @see org.apache.activemq.store.TransactionStore#rollback(TransactionId)
*/
public void rollback(TransactionId txid) throws IOException {
Tx tx = null;
synchronized (inflightTransactions) {
tx = inflightTransactions.remove(txid);
}
if (tx != null) {
synchronized (preparedTransactions) {
tx = preparedTransactions.remove(txid);
}
}
if (tx != null) {
if (txid.isXATransaction()) {
peristenceAdapter.writeCommand(new JournalTransaction(JournalTransaction.XA_ROLLBACK, txid,
false), true);
} else {
peristenceAdapter.writeCommand(new JournalTransaction(JournalTransaction.LOCAL_ROLLBACK,
txid, false), true);
}
}
}
示例3: processBeginTransaction
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
@Override
public Response processBeginTransaction(TransactionInfo info) throws Exception {
final TransactionId txID = info.getTransactionId();
try {
internalSession.resetTX(null);
if (txID.isXATransaction()) {
Xid xid = OpenWireUtil.toXID(txID);
internalSession.xaStart(xid);
} else {
Transaction transaction = internalSession.newTransaction();
txMap.put(txID, transaction);
transaction.addOperation(new TransactionOperationAbstract() {
@Override
public void afterCommit(Transaction tx) {
txMap.remove(txID);
}
});
}
} finally {
internalSession.resetTX(null);
}
return null;
}
示例4: processForgetTransaction
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
@Override
public Response processForgetTransaction(TransactionInfo info) throws Exception {
TransactionId txID = info.getTransactionId();
if (txID.isXATransaction()) {
try {
Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaForget(xid);
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e;
}
} else {
txMap.remove(txID);
}
return null;
}
示例5: processPrepareTransaction
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
@Override
public Response processPrepareTransaction(TransactionInfo info) throws Exception {
TransactionId txID = info.getTransactionId();
try {
if (txID.isXATransaction()) {
try {
Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaPrepare(xid);
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e;
}
} else {
Transaction tx = lookupTX(txID, null);
tx.prepare();
}
} finally {
internalSession.resetTX(null);
}
return new IntegerResponse(XAResource.XA_RDONLY);
}
示例6: processEndTransaction
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
@Override
public Response processEndTransaction(TransactionInfo info) throws Exception {
TransactionId txID = info.getTransactionId();
if (txID.isXATransaction()) {
try {
Transaction tx = lookupTX(txID, null);
internalSession.resetTX(tx);
try {
Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaEnd(xid);
} finally {
internalSession.resetTX(null);
}
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e;
}
} else {
txMap.remove(txID);
}
return null;
}
示例7: lookupTX
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
private Transaction lookupTX(TransactionId txID, AMQSession session, boolean remove) throws IllegalStateException {
if (txID == null) {
return null;
}
Xid xid = null;
Transaction transaction;
if (txID.isXATransaction()) {
xid = OpenWireUtil.toXID(txID);
transaction = remove ? server.getResourceManager().removeTransaction(xid) : server.getResourceManager().getTransaction(xid);
} else {
transaction = remove ? txMap.remove(txID) : txMap.get(txID);
}
if (transaction == null) {
return null;
}
if (session != null && transaction.getProtocolData() != session) {
transaction.setProtocolData(session);
}
return transaction;
}
示例8: commit
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
/**
* @throws XAException
* @see org.apache.activemq.store.TransactionStore#commit(org.apache.activemq.service.Transaction)
*/
public void commit(TransactionId txid, boolean wasPrepared, Runnable preCommit,Runnable postCommit) throws IOException {
Tx tx;
if (preCommit != null) {
preCommit.run();
}
if (wasPrepared) {
synchronized (preparedTransactions) {
tx = preparedTransactions.remove(txid);
}
} else {
synchronized (inflightTransactions) {
tx = inflightTransactions.remove(txid);
}
}
if (tx == null) {
if (postCommit != null) {
postCommit.run();
}
return;
}
if (txid.isXATransaction()) {
peristenceAdapter.writeCommand(new JournalTransaction(JournalTransaction.XA_COMMIT, txid,
wasPrepared), true);
} else {
peristenceAdapter.writeCommand(new JournalTransaction(JournalTransaction.LOCAL_COMMIT, txid,
wasPrepared), true);
}
if (postCommit != null) {
postCommit.run();
}
}
示例9: prepare
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
/**
* @throws IOException
* @see org.apache.activemq.store.TransactionStore#prepare(TransactionId)
*/
public void prepare(TransactionId txid) throws IOException {
KahaTransactionInfo info = getTransactionInfo(txid);
if (txid.isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) {
theStore.store(new KahaPrepareCommand().setTransactionInfo(info), true, null, null);
} else {
Tx tx = inflightTransactions.remove(txid);
if (tx != null) {
theStore.store(new KahaPrepareCommand().setTransactionInfo(info), true, null, null);
}
}
}
示例10: rollback
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
/**
* @throws IOException
* @see org.apache.activemq.store.TransactionStore#rollback(TransactionId)
*/
public void rollback(TransactionId txid) throws IOException {
if (txid.isXATransaction() || theStore.isConcurrentStoreAndDispatchTransactions() == false) {
KahaTransactionInfo info = getTransactionInfo(txid);
theStore.store(new KahaRollbackCommand().setTransactionInfo(info), false, null, null);
forgetRecoveredAcks(txid);
} else {
inflightTransactions.remove(txid);
}
}
示例11: forgetRecoveredAcks
import org.apache.activemq.command.TransactionId; //导入方法依赖的package包/类
protected void forgetRecoveredAcks(TransactionId txid) throws IOException {
if (txid.isXATransaction()) {
XATransactionId xaTid = ((XATransactionId) txid);
theStore.forgetRecoveredAcks(xaTid.getPreparedAcks());
}
}