public void SetupReceivedMessages()
        {
            var logger = new RecordingLogger();

            sender = ObjectMother.QueueManager(logger: logger);
            sender.Start();

            using (var tx = new TransactionScope())
            {
                sender.Send(
                    new Uri("lq.tcp://localhost:23457/h"),
                    new MessagePayload
                {
                    Data = new byte[] { 6, 7, 8, 9 }
                });

                tx.Complete();
            }

            receiver = ObjectMother.QueueManager("test2", 23457);
            receiver.CreateQueues("a");

            receiver.Start();
            sender.WaitForAllMessagesToBeSent();

            sender.Dispose();
            receiver.Dispose();

            sender   = ObjectMother.QueueManager(delete: false);
            receiver = ObjectMother.QueueManager("test2", 23457, delete: false);
            receiver.CreateQueues("a");
        }
Beispiel #2
0
        public void MessageSent_EventIsRaised()
        {
            using (var receiver = ObjectMother.QueueManager(TEST_QUEUE_2, 23457))
            {
                receiver.Start();

                using (var tx = new TransactionScope())
                {
                    _sender.Send(
                        new Uri("lq.tcp://localhost:23457/h"),
                        new MessagePayload
                    {
                        Data = new byte[] { 1, 2, 4, 5 }
                    });

                    tx.Complete();
                }
                _sender.WaitForAllMessagesToBeSent();
            }

            var log = _logger.DebugMessages.OfType <MessagesSent>().FirstOrDefault();

            log.ShouldNotBeNull();
            "localhost".ShouldEqual(log.Destination.Host);
            23457.ShouldEqual(log.Destination.Port);
            "h".ShouldEqual(log.Messages[0].Queue);
        }
Beispiel #3
0
 public void Setup()
 {
     _logger = new RecordingLogger();
     _sender = ObjectMother.QueueManager();
     _sender.Start();
     _receiver = ObjectMother.QueueManager("test2", 23457, logger: _logger);
     _receiver.Start();
 }
Beispiel #4
0
        public void ThrowsWhenAlreadyInUse()
        {
            var one = ObjectMother.QueueManager();
            var two = ObjectMother.QueueManager("test2");

            one.Start();
            typeof(EndpointInUseException).ShouldBeThrownBy(two.Start);
        }
Beispiel #5
0
        public void Setup()
        {
            _sender = ObjectMother.QueueManager();
            _sender.Start();

            _receiver = ObjectMother.QueueManager("test2", 23457);
            _receiver.CreateQueues("a");
            _receiver.Start();
        }
Beispiel #6
0
        public void rollback_on_send_does_not_send_message()
        {
            var sender       = ObjectMother.QueueManager("test2", 23457);
            var sendingScope = sender.BeginTransactionalScope();

            sendingScope.Send(ObjectMother.UriFor(23456), ObjectMother.MessagePayload());
            sendingScope.Rollback();

            var receivingScope = queueManager.BeginTransactionalScope();

            Assert.Throws <TimeoutException>(() => receivingScope.Receive("h", TimeSpan.FromSeconds(1)));
            sender.Dispose();
        }
        public void Setup()
        {
            _queue = ObjectMother.QueueManager();
            _queue.Start();

            _receiver = ObjectMother.QueueManager("test2", 23457);
            using (var tx = new TransactionScope())
            {
                _messageId = _queue.Send(
                    new Uri("lq.tcp://localhost:23457/h"),
                    new MessagePayload
                {
                    Data = new byte[] { 1, 2, 4, 5 }
                });

                tx.Complete();
            }
        }
Beispiel #8
0
        public void CanPurgeLargeSetsOfOldData()
        {
            queueManager = ObjectMother.QueueManager();
            queueManager.Configuration.OldestMessageInOutgoingHistory = TimeSpan.Zero;
            queueManager.Start();

            // Seed the queue with historical messages to be purged
            QueueMessagesThreaded(1000);
            //Parallel.For(0, 1000, new ParallelOptions { MaxDegreeOfParallelism = 8 }, i => SendMessages());

            queueManager.WaitForAllMessagesToBeSent();

            // Try to purge while still sending new messages.
            var waitHandle = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem(_ =>
            {
                queueManager.PurgeOldData();
                Console.WriteLine("Finished purging data");
                waitHandle.Set();
            });
            QueueMessagesThreaded(10000);
            //var purgeTask = Task.Factory.StartNew(() =>
            //{
            //    queueManager.PurgeOldData();
            //    Console.WriteLine("Finished purging data");
            //});
            //Parallel.For(0, 10000, new ParallelOptions { MaxDegreeOfParallelism = 8 }, i => SendMessages());

            waitHandle.WaitOne();
            //purgeTask.Wait();
            queueManager.WaitForAllMessagesToBeSent();

            queueManager.PurgeOldData();

            queueManager.Configuration.NumberOfMessagesToKeepInOutgoingHistory.ShouldEqual(
                queueManager.GetAllSentMessages().Length);
        }
 private void SetupUnstarted()
 {
     sender   = ObjectMother.QueueManager();
     receiver = ObjectMother.QueueManager("test2", 23457);
     receiver.CreateQueues("a");
 }
Beispiel #10
0
 public void Setup()
 {
     _logger = new RecordingLogger();
     _sender = ObjectMother.QueueManager(logger: _logger);
     _sender.Start();
 }
Beispiel #11
0
 public void SetUp()
 {
     queueManager = ObjectMother.QueueManager();
     queueManager.Start();
 }
 public void Setup()
 {
     queueManager = ObjectMother.QueueManager();
 }
Beispiel #13
0
 public void Setup()
 {
     _sender   = ObjectMother.QueueManager();
     _receiver = ObjectMother.QueueManager("test2", 23457);
 }