store.replayAddMessage(msg);
transactionCounter++;
}
}
else if (packet instanceof MessageAck) {
MessageAck ack = (MessageAck) packet;
JournalMessageStore store = (JournalMessageStore) createMessageStore(destination, ack.getDestination().isQueue());
if( ack.getTransactionId()!=null ) {
transactionStore.removeMessage(store, ack, pos);
} else {
store.replayRemoveMessage(ack);
transactionCounter++;
}
}
else {
log.error("Unknown type of packet in transaction log which will be discarded: " + packet);
}
break;
case TX_COMMAND_RECORD_TYPE:
TxCommand command = new TxCommand();
command.setType(is.readByte());
command.setWasPrepared(is.readBoolean());
switch(command.getType()) {
case TxCommand.LOCAL_COMMIT:
case TxCommand.LOCAL_ROLLBACK:
command.setTransactionId(is.readUTF());
break;
default:
command.setTransactionId(ActiveMQXid.read(is));
break;
}
// Try to replay the packet.
switch(command.getType()) {
case TxCommand.XA_PREPARE:
transactionStore.replayPrepare(command.getTransactionId());
break;
case TxCommand.XA_COMMIT:
case TxCommand.LOCAL_COMMIT:
Tx tx = transactionStore.replayCommit(command.getTransactionId(), command.getWasPrepared());
// Replay the committed operations.
tx.getOperations();
for (Iterator iter = tx.getOperations().iterator(); iter.hasNext();) {
TxOperation op = (TxOperation) iter.next();
if( op.operationType == TxOperation.ADD_OPERATION_TYPE ) {
op.store.replayAddMessage((ActiveMQMessage) op.data);
}
if( op.operationType == TxOperation.REMOVE_OPERATION_TYPE) {
op.store.replayRemoveMessage((MessageAck) op.data);
}
if( op.operationType == TxOperation.ACK_OPERATION_TYPE) {
JournalAck ack = (JournalAck) op.data;
((JournalTopicMessageStore)op.store).replayAcknowledge(ack.getSubscription(), new MessageIdentity(ack.getMessageId()));
}
}
transactionCounter++;
break;
case TxCommand.LOCAL_ROLLBACK: