当前位置: 首页>>代码示例>>Java>>正文


Java TransactionId类代码示例

本文整理汇总了Java中org.apache.activemq.command.TransactionId的典型用法代码示例。如果您正苦于以下问题:Java TransactionId类的具体用法?Java TransactionId怎么用?Java TransactionId使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionId类属于org.apache.activemq.command包,在下文中一共展示了TransactionId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
public static KahaTransactionInfo convert(TransactionId txid) {
    if (txid == null) {
        return null;
    }
    KahaTransactionInfo rc;

    if (txid.isLocalTransaction()) {
        rc = convertToLocal(txid);
    } else {
        rc = new KahaTransactionInfo();
        XATransactionId t = (XATransactionId) txid;
        KahaXATransactionId kahaTxId = new KahaXATransactionId();
        kahaTxId.setBranchQualifier(new Buffer(t.getBranchQualifier()));
        kahaTxId.setGlobalTransactionId(new Buffer(t.getGlobalTransactionId()));
        kahaTxId.setFormatId(t.getFormatId());
        rc.setXaTransactionId(kahaTxId);
    }
    return rc;
}
 
开发者ID:Hill30,项目名称:amq-kahadb-tool,代码行数:20,代码来源:KahaDBTransactionIdConversion.java

示例2: commandAnalysis

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
private void commandAnalysis(KahaCommitCommand command, Location location) {
    if(!command.hasTransactionInfo()) {
        return;
    }

    TransactionId transactionId = KahaDBTransactionIdConversion.convert(command.getTransactionInfo());
    List<OperationLocation> inflightTx = inflightedTransactions.remove(transactionId);
    if(inflightTx == null) {
        TransactionLocation prepareMessageLocation = preparedTransactions.remove(transactionId);
        inflightTx = prepareMessageLocation == null ? null : prepareMessageLocation.getOperationLocations();
    }

    if(inflightTx != null) {
        CommittedTransactionLocation committedTransactionLocation = new CommittedTransactionLocation(transactionId, location, inflightTx);
        committedTransactionLocations.put(committedTransactionLocation.getTransactionId(), committedTransactionLocation);

        inflightTx.forEach(OperationLocation::execute);
    }
}
 
开发者ID:Hill30,项目名称:amq-kahadb-tool,代码行数:20,代码来源:PoolDestinationData.java

示例3: 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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:OpenWireConnection.java

示例4: getPreparedTransactions

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception {
    List<TransactionId> txs = new ArrayList<TransactionId>();
    synchronized (xaTransactions) {
        for (Iterator<XATransaction> iter = xaTransactions.values().iterator(); iter.hasNext();) {
            Transaction tx = iter.next();
            if (tx.isPrepared()) {
                LOG.debug("prepared transaction: {}", tx.getTransactionId());
                txs.add(tx.getTransactionId());
            }
        }
    }
    XATransactionId rc[] = new XATransactionId[txs.size()];
    txs.toArray(rc);
    LOG.debug("prepared transaction list size: {}", rc.length);
    return rc;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:17,代码来源:TransactionBroker.java

示例5: getTransactions

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public String getTransactions() {

    ArrayList<TranInfo> infos = new ArrayList<TranInfo>();
    synchronized (inflightTransactions) {
        if (!inflightTransactions.isEmpty()) {
            for (Entry<TransactionId, List<Operation>> entry : inflightTransactions.entrySet()) {
                TranInfo info = new TranInfo();
                info.id = entry.getKey();
                for (Operation operation : entry.getValue()) {
                    info.track(operation);
                }
                infos.add(info);
            }
        }
    }
    return infos.toString();
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:MessageDatabase.java

示例6: 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.");
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:18,代码来源:TransactionBroker.java

示例7: onStompMessageNack

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
public MessageAck onStompMessageNack(String messageId, TransactionId transactionId) throws ProtocolException {

        MessageId msgId = new MessageId(messageId);

        if (!dispatchedMessage.containsKey(msgId)) {
            return null;
        }

        MessageAck ack = new MessageAck();
        ack.setDestination(consumerInfo.getDestination());
        ack.setConsumerId(consumerInfo.getConsumerId());
        ack.setAckType(MessageAck.POSION_ACK_TYPE);
        ack.setMessageID(msgId);
        if (transactionId != null) {
            unconsumedMessage.add(dispatchedMessage.get(msgId));
            ack.setTransactionId(transactionId);
        }
        dispatchedMessage.remove(msgId);

        return ack;
    }
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:22,代码来源:StompSubscription.java

示例8: commit

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
public void commit(TransactionId txid, boolean wasPrepared, Runnable preCommit,Runnable postCommit) throws IOException {
    if (preCommit != null) {
        preCommit.run();
    }
    Tx tx;
    if (wasPrepared) {
        tx = preparedTransactions.remove(txid);
    } else {
        tx = inflightTransactions.remove(txid);
    }

    if (tx != null) {
        tx.commit();
    }
    if (postCommit != null) {
        postCommit.run();
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:19,代码来源:MemoryTransactionStore.java

示例9: 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;
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:OpenWireConnection.java

示例10: recover

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
public synchronized void recover(TransactionRecoveryListener listener) throws IOException {
    // All the in-flight transactions get rolled back..
    synchronized (inflightTransactions) {
        inflightTransactions.clear();
    }
    this.doingRecover = true;
    try {
        Map<TransactionId, Tx> txs = null;
        synchronized (preparedTransactions) {
            txs = new LinkedHashMap<TransactionId, Tx>(preparedTransactions);
        }
        for (Iterator<TransactionId> iter = txs.keySet().iterator(); iter.hasNext();) {
            Object txid = iter.next();
            Tx tx = txs.get(txid);
            listener.recover((XATransactionId)txid, tx.getMessages(), tx.getAcks());
        }
    } finally {
        this.doingRecover = false;
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:21,代码来源:JournalTransactionStore.java

示例11: convert

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
static KahaTransactionInfo convert(TransactionId txid) {
    if (txid == null) {
        return null;
    }
    KahaTransactionInfo rc;

    if (txid.isLocalTransaction()) {
        rc = convertToLocal(txid);
    } else {
        rc = new KahaTransactionInfo();
        XATransactionId t = (XATransactionId) txid;
        KahaXATransactionId kahaTxId = new KahaXATransactionId();
        kahaTxId.setBranchQualifier(new Buffer(t.getBranchQualifier()));
        kahaTxId.setGlobalTransactionId(new Buffer(t.getGlobalTransactionId()));
        kahaTxId.setFormatId(t.getFormatId());
        rc.setXaTransactionId(kahaTxId);
    }
    return rc;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:20,代码来源:TransactionIdConversion.java

示例12: convertToLocal

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
public static KahaTransactionInfo convertToLocal(TransactionId tx) {
    if(tx == null) {
        throw new NullPointerException("tx");
    }

    KahaTransactionInfo rc = new KahaTransactionInfo();
    LocalTransactionId t = (LocalTransactionId) tx;
    KahaLocalTransactionId kahaTxId = new KahaLocalTransactionId();
    kahaTxId.setConnectionId(t.getConnectionId().getValue());
    kahaTxId.setTransactionId(t.getValue());
    rc.setLocalTransactionId(kahaTxId);
    return rc;
}
 
开发者ID:Hill30,项目名称:amq-kahadb-tool,代码行数:14,代码来源:KahaDBTransactionIdConversion.java

示例13: getInflightTx

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
private List<OperationLocation> getInflightTx(KahaTransactionInfo info) {
    TransactionId transactionId = KahaDBTransactionIdConversion.convert(info);
    List<OperationLocation> inflightTx = inflightedTransactions.get(transactionId);

    if(inflightTx == null) {
        inflightTx = new ArrayList<>();
        inflightedTransactions.put(transactionId, inflightTx);
    }

    return inflightTx;
}
 
开发者ID:Hill30,项目名称:amq-kahadb-tool,代码行数:12,代码来源:PoolDestinationData.java

示例14: commitTransaction

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
@Override
public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception {
    next.commitTransaction(context, xid, onePhase);
    Broker brokers[] = getListeners();
    for (int i = 0; i < brokers.length; i++) {
        brokers[i].commitTransaction(context, xid, onePhase);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:9,代码来源:BrokerBroadcaster.java

示例15: prepareTransaction

import org.apache.activemq.command.TransactionId; //导入依赖的package包/类
@Override
public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception {
    int result = next.prepareTransaction(context, xid);
    Broker brokers[] = getListeners();
    for (int i = 0; i < brokers.length; i++) {
        // TODO decide what to do with return values
        brokers[i].prepareTransaction(context, xid);
    }
    return result;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:11,代码来源:BrokerBroadcaster.java


注:本文中的org.apache.activemq.command.TransactionId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。