本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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.");
}
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}