예제 #1
0
        public void TestQueue()
        {
            using (var dl = new DisposableList())
            {
                var docs     = TestHelpers.CreateStarDocuments(3);
                var original = DocdbGatewayMessage.Create("Star", docs);

                var queue = new QueueWrapper(TestHelpers.GenUnique("gateq"), TestConfig.GatewayStorageAccount);
                dl.Add(queue.Delete);

                var blobStorage           = new InMemoryGatewayBlobStore();
                GatewayQueueWriter writer = new GatewayQueueWriter(queue, blobStorage);
                writer.Write(original);

                GatewayQueueReader reader = new GatewayQueueReader(queue, blobStorage);
                reader.ReadNextMessage <DocdbGatewayMessage>(
                    gm =>
                {
                    var rdocs = gm.DocumentsAs <StarDocument>().ToList();
                    Assert.AreEqual(docs.Count, rdocs.Count);

                    for (int i = 0; i < rdocs.Count; ++i)
                    {
                        TestHelpers.AssertEqualStars(docs[i], rdocs[i]);
                    }
                },
                    (e, gm, cqm) => Assert.Fail());
            }
        }
예제 #2
0
        public void TestQueueBig()
        {
            using (var dl = new DisposableList())
            {
                var entities = TestHelpers.CreateStarEntities(10000);
                var original = TableGatewayMessage.Create("Star", entities);

                var queue = new QueueWrapper(TestHelpers.GenUnique("gateq"), TestConfig.GatewayStorageAccount);
                var bcont = new BlobContainerWrapper(TestHelpers.GenUnique("gatecont"), TestConfig.GatewayStorageAccount);
                dl.Add(queue.Delete);
                dl.Add(bcont.Delete);

                var blobStorage           = new GatewayBlobStore(bcont);
                GatewayQueueWriter writer = new GatewayQueueWriter(queue, blobStorage);
                writer.Write(original);

                GatewayQueueReader reader = new GatewayQueueReader(queue, blobStorage);
                reader.ReadNextMessage <TableGatewayMessage>(
                    gm =>
                {
                    var rentities = gm.EntitiesAs <StarEntity>().ToList();
                    Assert.AreEqual(entities.Count, rentities.Count);

                    for (int i = 0; i < rentities.Count; ++i)
                    {
                        TestHelpers.AssertEqualStars(entities[i], rentities[i]);
                    }
                },
                    (e, gm, cqm) => Assert.Fail());
            }
        }
        /// <summary>
        /// Processes next message from the queue.
        /// </summary>
        /// <returns>False if queue is empty, otherwise - True.</returns>
        public bool ProcessNext(out bool discarded)
        {
            bool d      = false;
            bool result = _queueReader.ReadNextMessage <DocdbGatewayMessage>(
                m => { d = DispatchMessage(m); },
                OnError
                );

            discarded = d;
            return(result);
        }
예제 #4
0
        public void TestMultiQueueBig()
        {
            using (var dl = new DisposableList())
            {
                var entities = TestHelpers.CreateStarEntities(10000);
                var original = TableGatewayMessage.Create("Star", entities);

                List <QueueWrapper> queues = new List <QueueWrapper>();
                for (int i = 0; i < 3; ++i)
                {
                    var queue = new QueueWrapper(TestHelpers.GenUnique("gateq" + i), TestConfig.GatewayStorageAccount);
                    dl.Add(queue.Delete);
                    queues.Add(queue);
                }

                var blobStorage = new InMemoryGatewayBlobStore();
                GatewayMultiQueueWriter writer = new GatewayMultiQueueWriter(queues, blobStorage);
                writer.Write(original);
                Assert.AreEqual(1, blobStorage.Count);

                foreach (var queue in queues)
                {
                    GatewayQueueReader reader = new GatewayQueueReader(queue, blobStorage);
                    bool processed            = false;
                    reader.ReadNextMessage <TableGatewayMessage>(
                        gm =>
                    {
                        var rentities = gm.EntitiesAs <StarEntity>().ToList();
                        Assert.AreEqual(entities.Count, rentities.Count);

                        for (int i = 0; i < rentities.Count; ++i)
                        {
                            TestHelpers.AssertEqualStars(entities[i], rentities[i]);
                        }

                        processed = true;
                    },
                        (e, gm, cqm) => Assert.Fail());

                    Assert.IsTrue(processed);
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Processes next message from the queue.
 /// </summary>
 /// <returns>False if queue is empty, otherwise - true.</returns>
 public bool ProcessNext()
 {
     return(_queueReader.ReadNextMessage <TableGatewayMessage>(DispatchMessage, OnError));
 }