* @return
*/
public RecordLocation writeTxCommand(TxCommand command, boolean sync) throws XAException {
try {
PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(pos);
os.writeByte(TX_COMMAND_RECORD_TYPE);
os.writeByte(command.getType());
os.writeBoolean(command.getWasPrepared());
switch(command.getType()) {
case TxCommand.LOCAL_COMMIT:
case TxCommand.LOCAL_ROLLBACK:
os.writeUTF( (String) command.getTransactionId() );
break;
default:
ActiveMQXid xid = (ActiveMQXid) command.getTransactionId();
xid.write(os);
break;
}
os.close();
return journal.write(pos.getPacket(), sync);
}
catch (IOException e) {
throw createWriteException(command, e);
}
}