Apache.NMS.ActiveMQ.Transactions.RecoveryFileLogger.GetRecoverables C# (CSharp) Method

GetRecoverables() public method

public GetRecoverables ( ) : byte[]>[].KeyValuePair
return byte[]>[].KeyValuePair
        public KeyValuePair<XATransactionId, byte[]>[] GetRecoverables()
        {
            KeyValuePair<XATransactionId, byte[]>[] result = new KeyValuePair<XATransactionId, byte[]>[0];
            RecoveryInformation info = TryOpenRecoveryInfoFile();

            if (info != null)
            {
                result = new KeyValuePair<XATransactionId, byte[]>[1];
                result[0] = new KeyValuePair<XATransactionId, byte[]>(info.Xid, info.TxRecoveryInfo);
            }

            return result;
        }

Usage Example

コード例 #1
0
        public void TestRecoverLoggedRecord()
        {
            RecoveryFileLogger logger = new RecoveryFileLogger();

            byte[] globalId = new byte[32];
            byte[] branchQ = new byte[32];
            byte[] recoveryData = new byte[256];

            Random gen = new Random();

            gen.NextBytes(globalId);
            gen.NextBytes(branchQ);
            gen.NextBytes(recoveryData);

            logger.Location = nonDefaultLogLocation;
            logger.Initialize(rmId.ToString());

            XATransactionId xid = new XATransactionId();
            xid.GlobalTransactionId = globalId;
            xid.BranchQualifier = branchQ;

            logger.LogRecoveryInfo(xid, recoveryData);

            Assert.IsTrue(File.Exists(logger.Location + Path.DirectorySeparatorChar + rmId.ToString() + ".bin"),
                          "Recovery File was not created");
            Assert.IsTrue(logger.GetRecoverables().Length == 1,
                          "Did not recover the logged record.");

            KeyValuePair<XATransactionId, byte[]>[] records = logger.GetRecoverables();
            Assert.AreEqual(1, records.Length);

            Assert.AreEqual(globalId, records[0].Key.GlobalTransactionId, "Incorrect Global TX Id returned");
            Assert.AreEqual(branchQ, records[0].Key.BranchQualifier, "Incorrect Branch Qualifier returned");
            Assert.AreEqual(recoveryData, records[0].Value, "Incorrect Recovery Information returned");
        }
All Usage Examples Of Apache.NMS.ActiveMQ.Transactions.RecoveryFileLogger::GetRecoverables