public AMQTx readPayload(DataInput dataIn) throws IOException { Location location = new Location(); location.readExternal(dataIn); AMQTx result = new AMQTx(location); int size = dataIn.readInt(); for (int i = 0; i < size; i++) { AMQTxOperation op = new AMQTxOperation(); op.readExternal(wireFormat, dataIn); result.getOperations().add(op); } return result; }
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, AMQTx> txs = null; synchronized (preparedTransactions) { txs = new LinkedHashMap<TransactionId, AMQTx>(preparedTransactions); } for (Iterator<TransactionId> iter = txs.keySet().iterator(); iter.hasNext();) { Object txid = iter.next(); AMQTx tx = txs.get(txid); listener.recover((XATransactionId)txid, tx.getMessages(), tx.getAcks()); } } finally { this.doingRecover = false; } }
public void writePayload(AMQTx amqtx, DataOutput dataOut) throws IOException { amqtx.getLocation().writeExternal(dataOut); List<AMQTxOperation> list = amqtx.getOperations(); List<AMQTxOperation> ops = new ArrayList<AMQTxOperation>(); for (AMQTxOperation op : list) { if (op.getOperationType() == op.ADD_OPERATION_TYPE) { ops.add(op); } } dataOut.writeInt(ops.size()); for (AMQTxOperation op : ops) { op.writeExternal(wireFormat, dataOut); } } }
public void acknowledge(AMQTopicMessageStore store, JournalTopicAck ack, Location location) { AMQTx tx = getTx(ack.getTransactionId(), location); tx.add(store, ack); }
public AMQTx getTx(TransactionId txid, Location location) { AMQTx tx = null; synchronized (inflightTransactions) { tx = inflightTransactions.get(txid); if (tx == null) { tx = new AMQTx(location); inflightTransactions.put(txid, tx); } } return tx; }
public Location checkpoint() throws IOException { // Nothing really to checkpoint.. since, we don't // checkpoint tx operations in to long term store until they are // committed. // But we keep track of the first location of an operation // that was associated with an active tx. The journal can not // roll over active tx records. Location minimumLocationInUse = null; synchronized (inflightTransactions) { for (Iterator<AMQTx> iter = inflightTransactions.values().iterator(); iter.hasNext();) { AMQTx tx = iter.next(); Location location = tx.getLocation(); if (minimumLocationInUse == null || location.compareTo(minimumLocationInUse) < 0) { minimumLocationInUse = location; } } } synchronized (preparedTransactions) { for (Iterator<AMQTx> iter = preparedTransactions.values().iterator(); iter.hasNext();) { AMQTx tx = iter.next(); Location location = tx.getLocation(); if (minimumLocationInUse == null || location.compareTo(minimumLocationInUse) < 0) { minimumLocationInUse = location; } } return minimumLocationInUse; } }
tx.getOperations(); for (Iterator iter = tx.getOperations().iterator(); iter.hasNext();) { AMQTxOperation op = (AMQTxOperation)iter.next(); if (op.replay(this, context)) {
/** * @param ack * @throws IOException */ public void removeMessage(AMQMessageStore store, MessageAck ack, Location location) throws IOException { AMQTx tx = getTx(ack.getTransactionId(), location); tx.add(store, ack); }
/** * @param message * @throws IOException */ void addMessage(AMQMessageStore store, Message message, Location location) throws IOException { AMQTx tx = getTx(message.getTransactionId(), location); tx.add(store, message, location); }