SetFailInterval() public method

public SetFailInterval ( int value ) : void
value int
return void
コード例 #1
0
        public void Can_Deliver_Many_Messages_With_Failures()
        {
            using (var serviceBusRuntime = Create.MsmqRuntime <IContract>())
            {
                ServiceBusTest tester = new ServiceBusTest(serviceBusRuntime);
                tester.OnlyRetryOnce();

                ContractImplementation ci = new ContractImplementation();
                ci.SetFailCount(0);
                ci.SetFailInterval(10);

                QueuedDeliveryCore qc = serviceBusRuntime.ServiceLocator.GetInstance <QueuedDeliveryCore>();
                qc.RetryDelay = 1;

                tester.AddTestListener();
                tester.AddTestSubscription(ci, new PassThroughMessageFilter());

                int messageCount = 1000;

                DateTime start = DateTime.Now;


                tester.WaitForDeliveries(messageCount * 2, TimeSpan.FromMinutes(1), () =>
                {
                    for (int i = 0; i < messageCount; i++)
                    {
                        string message = i.ToString();
                        serviceBusRuntime.PublishOneWay(new PublishRequest(typeof(IContract), "PublishThis", message));
                    }
                });


                bool[] results = new bool[messageCount];
                // Wait for delivery
                DateTime end = DateTime.Now;
                System.Diagnostics.Trace.TraceInformation("Time to deliver " + messageCount + " = " + (end - start));

                for (int i = 0; i < ci.PublishedCount; i++)
                {
                    results[Convert.ToInt32(ci.PublishedMessages[i])] = true;
                }

                for (int i = 0; i < messageCount; i++)
                {
                    Assert.IsTrue(results[i]);
                }

                Assert.AreEqual(messageCount, ci.PublishedCount);
                tester.VerifyQueuesEmpty();
            }
        }
コード例 #2
0
        public void Can_Deliver_Many_Messages_With_Failures()
        {
            using (var serviceBusRuntime = Create.MsmqRuntime<IContract>())
            {
                ServiceBusTest tester = new ServiceBusTest(serviceBusRuntime);
                tester.OnlyRetryOnce();

                ContractImplementation ci = new ContractImplementation();
                ci.SetFailCount(0);
                ci.SetFailInterval(10);

                QueuedDeliveryCore qc = serviceBusRuntime.ServiceLocator.GetInstance<QueuedDeliveryCore>();
                qc.RetryDelay = 1;

                tester.AddTestListener();
                tester.AddTestSubscription(ci, new PassThroughMessageFilter());

                int messageCount = 1000;

                DateTime start = DateTime.Now;

                tester.WaitForDeliveries(messageCount*2, TimeSpan.FromMinutes(1), () =>
                {
                    for (int i = 0; i < messageCount; i++)
                    {
                        string message = i.ToString();
                        serviceBusRuntime.PublishOneWay(new PublishRequest(typeof(IContract), "PublishThis", message));
                    }
                });

                bool[] results = new bool[messageCount];
                // Wait for delivery
                DateTime end = DateTime.Now;
                System.Diagnostics.Trace.TraceInformation("Time to deliver " + messageCount + " = " + (end - start));

                for (int i = 0; i < ci.PublishedCount; i++)
                {
                    results[Convert.ToInt32(ci.PublishedMessages[i])] = true;
                }

                for (int i = 0; i < messageCount; i++)
                {
                    Assert.IsTrue(results[i]);
                }

                Assert.AreEqual(messageCount, ci.PublishedCount);
                tester.VerifyQueuesEmpty();
            }
        }