예제 #1
0
        public void High_volume_scheduling_test_with_future_date()
        {
            bus.Subscribe <PartyInvitation>("schedulingTest1", m => Console.WriteLine("Got scheduled message: {0}", m.Text));

            var count = 0;

            while (true)
            {
                var invitation = new PartyInvitation
                {
                    Text = string.Format("Invitation {0}", count++),
                    Date = new DateTime(2011, 5, 24)
                };

                bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
                Thread.Sleep(1);
            }
        }
예제 #2
0
        public void Should_be_able_to_schedule_a_message_with_future_date()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                autoResetEvent.Set();
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);

            autoResetEvent.WaitOne(10000);
        }
        public void High_volume_scheduling_test_with_delay()
        {
            logger.Debug = false;

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
                Console.WriteLine("Got scheduled message: {0}", message.Text));

            var count = 0;
            while (true)
            {
                var invitation = new PartyInvitation
                {
                    Text = string.Format("Invitation {0}", count++),
                    Date = new DateTime(2011, 5, 24)
                };

                bus.FuturePublish(TimeSpan.FromSeconds(3), invitation);
                Thread.Sleep(1);
            }
        }
        public void Should_be_able_to_schedule_a_message_with_delay()
        {
            var autoResetEvent = new AutoResetEvent(false);

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                autoResetEvent.Set();
            });
            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(TimeSpan.FromSeconds(3), invitation);

            if (!autoResetEvent.WaitOne(100000))
                Assert.Fail();
        }
        public void High_volume_scheduling_test_with_delay()
        {
            logger.Debug = false;

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
                                            Console.WriteLine("Got scheduled message: {0}", message.Text));

            var count = 0;

            while (true)
            {
                var invitation = new PartyInvitation
                {
                    Text = string.Format("Invitation {0}", count++),
                    Date = new DateTime(2011, 5, 24)
                };

                bus.FuturePublish(TimeSpan.FromSeconds(3), invitation);
                Thread.Sleep(1);
            }
        }
예제 #6
0
        public void Should_be_able_to_cancel_a_message()
        {
            var messagesReceived = 0;

            bus.Subscribe <PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                messagesReceived++;
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.CancelFuturePublish("my_cancellation_key");

            Thread.Sleep(10000);
            Assert.Equal(1, messagesReceived);
        }
예제 #7
0
        public void Should_be_able_to_cancel_a_message()
        {
            var messagesReceived = 0;

            bus.Subscribe<PartyInvitation>("schedulingTest1", message =>
            {
                Console.WriteLine("Got scheduled message: {0}", message.Text);
                messagesReceived++;
            });

            var invitation = new PartyInvitation
            {
                Text = "Please come to my party",
                Date = new DateTime(2011, 5, 24)
            };

            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), invitation);
            bus.FuturePublish(DateTime.UtcNow.AddSeconds(3), "my_cancellation_key", invitation);
            bus.CancelFuturePublish("my_cancellation_key");

            Thread.Sleep(10000);
            Assert.AreEqual(1, messagesReceived);
        }