コード例 #1
0
ファイル: FileStorage.cs プロジェクト: JeetKunDoug/lokad-cqrs
        public static FilePartitionInbox CreateInbox(this FileStorageConfig cfg, string name, Func<uint, TimeSpan> decay = null)
        {
            var reader = new StatelessFileQueueReader(Path.Combine(cfg.FullPath, name), name);

            var waiter = decay ?? DecayEvil.BuildExponentialDecay(250);
            var inbox = new FilePartitionInbox(new[]{reader, }, waiter);
            inbox.Init();
            return inbox;
        }
コード例 #2
0
        public void when_take_message()
        {
            var queue1 = InitQueue("test1");

            var inbox = new FilePartitionInbox(new[] { queue1 }, x => new TimeSpan(x));
            inbox.InitIfNeeded();
            MessageTransportContext message1;
            inbox.TakeMessage(new CancellationToken(false), out message1);

            Assert.AreEqual("test1", message1.QueueName);
        }
コード例 #3
0
        public void when_init_of_needed()
        {
            var path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var queue = new StatelessFileQueueReader(path, "test");

            var inbox = new FilePartitionInbox(new[] { queue }, x => new TimeSpan(x));

            Assert.IsFalse(Directory.Exists(path));
            inbox.InitIfNeeded();
            Assert.IsTrue(Directory.Exists(path));
        }
コード例 #4
0
        public void when_ack_messages_by_name()
        {
            var queue1 = InitQueue("test1");

            var inbox = new FilePartitionInbox(new[] { queue1 }, x => new TimeSpan(x));
            inbox.InitIfNeeded();
            MessageTransportContext message1;
            inbox.TakeMessage(new CancellationToken(false), out message1);
            inbox.AckMessage(message1);

            Assert.IsFalse(new FileInfo(((FileInfo)message1.TransportMessage).FullName).Exists);
        }