public Tx getTx(Object txid) { Tx tx = inflightTransactions.get(txid); if (tx == null) { synchronized (inflightTransactions) { tx = inflightTransactions.get(txid); if ( tx == null) { tx = new Tx(); inflightTransactions.put(txid, tx); } } } return tx; }
@Override public void commit(TransactionId txid, boolean wasPrepared, Runnable preCommit, Runnable postCommit) throws IOException { if (preCommit != null) { preCommit.run(); } Tx tx; if (wasPrepared) { tx = preparedTransactions.get(txid); } else { tx = inflightTransactions.remove(txid); } if (tx != null) { tx.commit(); } if (wasPrepared) { preparedTransactions.remove(txid); } if (postCommit != null) { postCommit.run(); } }
@Override public synchronized void recover(TransactionRecoveryListener listener) throws IOException { // All the inflight transactions get rolled back.. inflightTransactions.clear(); this.doingRecover = true; try { for (Iterator<TransactionId> iter = preparedTransactions.keySet().iterator(); iter.hasNext();) { Object txid = iter.next(); Tx tx = preparedTransactions.get(txid); listener.recover((XATransactionId) txid, tx.getMessages(), tx.getAcks()); onRecovered(tx); } } finally { this.doingRecover = false; } }
final MessageAck ack = new MessageAck(); ack.setDestination(destination); tx.add(new LastAckCommand() { JDBCTopicMessageStore jdbcTopicMessageStore;
tx.add(new LastAckCommand() { public MessageAck getMessageAck() { return ack;
tx.add(new LastAckCommand() { public MessageAck getMessageAck() { return ack;
final MessageAck ack = new MessageAck(); ack.setDestination(destination); tx.add(new LastAckCommand() { JDBCTopicMessageStore jdbcTopicMessageStore;
tx.add(new LastAckCommand() { public MessageAck getMessageAck() { return ack;
final MessageAck ack = new MessageAck(); ack.setDestination(destination); tx.add(new LastAckCommand() { JDBCTopicMessageStore jdbcTopicMessageStore;
tx.add(new AddMessageCommand() { @SuppressWarnings("unused") MessageStore messageStore = destination;
tx.add(new AddMessageCommand() { @SuppressWarnings("unused") MessageStore messageStore = destination;
tx.add(new AddMessageCommand() { @SuppressWarnings("unused") MessageStore messageStore = destination;
public void acknowledge(final TopicMessageStore destination, final String clientId, final String subscriptionName, final MessageId messageId, final MessageAck ack) throws IOException { if (doingRecover) { return; } if (ack.isInTransaction()) { Tx tx = getTx(ack.getTransactionId()); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext ctx) throws IOException { destination.acknowledge(ctx, clientId, subscriptionName, messageId, ack); } @Override public MessageStore getMessageStore() { return destination; } }); } else { destination.acknowledge(null, clientId, subscriptionName, messageId, ack); } }
/** * @param ack * @throws IOException */ final void removeMessage(final MessageStore destination, final MessageAck ack) throws IOException { if (doingRecover) { return; } if (ack.isInTransaction()) { Tx tx = getTx(ack.getTransactionId()); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext ctx) throws IOException { destination.removeMessage(ctx, ack); } @Override public MessageStore getMessageStore() { return destination; } }); } else { destination.removeMessage(null, ack); } }
/** * @param ack * @throws IOException */ final void removeMessage(final MessageStore destination, final MessageAck ack) throws IOException { if (doingRecover) { return; } if (ack.isInTransaction()) { Tx tx = getTx(ack.getTransactionId()); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext ctx) throws IOException { destination.removeMessage(ctx, ack); } @Override public MessageStore getMessageStore() { return destination; } }); } else { destination.removeMessage(null, ack); } }
/** * @param ack * @throws IOException */ final void removeMessage(final MessageStore destination, final MessageAck ack) throws IOException { if (doingRecover) { return; } if (ack.isInTransaction()) { Tx tx = getTx(ack.getTransactionId()); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext ctx) throws IOException { destination.removeMessage(ctx, ack); } @Override public MessageStore getMessageStore() { return destination; } }); } else { destination.removeMessage(null, ack); } }
public void recoverAck(long id, byte[] xid, byte[] message) throws IOException { Message msg = (Message) ((JDBCPersistenceAdapter)persistenceAdapter).getWireFormat().unmarshal(new ByteSequence(message)); msg.getMessageId().setFutureOrSequenceLong(id); msg.getMessageId().setEntryLocator(id); Tx tx = getPreparedTx(new XATransactionId(xid)); final MessageAck ack = new MessageAck(msg, MessageAck.STANDARD_ACK_TYPE, 1); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext context) throws IOException { ((JDBCPersistenceAdapter)persistenceAdapter).commitRemove(context, ack); } @Override public MessageStore getMessageStore() { return null; } }); }
public void recoverAck(long id, byte[] xid, byte[] message) throws IOException { Message msg = (Message) ((JDBCPersistenceAdapter)persistenceAdapter).getWireFormat().unmarshal(new ByteSequence(message)); msg.getMessageId().setFutureOrSequenceLong(id); msg.getMessageId().setEntryLocator(id); Tx tx = getPreparedTx(new XATransactionId(xid)); final MessageAck ack = new MessageAck(msg, MessageAck.STANDARD_ACK_TYPE, 1); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext context) throws IOException { ((JDBCPersistenceAdapter)persistenceAdapter).commitRemove(context, ack); } @Override public MessageStore getMessageStore() { return null; } }); }
public void acknowledge(final TopicMessageStore destination, final String clientId, final String subscriptionName, final MessageId messageId, final MessageAck ack) throws IOException { if (doingRecover) { return; } if (ack.isInTransaction()) { Tx tx = getTx(ack.getTransactionId()); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext ctx) throws IOException { destination.acknowledge(ctx, clientId, subscriptionName, messageId, ack); } @Override public MessageStore getMessageStore() { return destination; } }); } else { destination.acknowledge(null, clientId, subscriptionName, messageId, ack); } }
public void recoverAck(long id, byte[] xid, byte[] message) throws IOException { Message msg = (Message) ((JDBCPersistenceAdapter)persistenceAdapter).getWireFormat().unmarshal(new ByteSequence(message)); msg.getMessageId().setFutureOrSequenceLong(id); msg.getMessageId().setEntryLocator(id); Tx tx = getPreparedTx(new XATransactionId(xid)); final MessageAck ack = new MessageAck(msg, MessageAck.STANDARD_ACK_TYPE, 1); tx.add(new RemoveMessageCommand() { @Override public MessageAck getMessageAck() { return ack; } @Override public void run(ConnectionContext context) throws IOException { ((JDBCPersistenceAdapter)persistenceAdapter).commitRemove(context, ack); } @Override public MessageStore getMessageStore() { return null; } }); }