示例#1
0
        public void BasicActivation_Reentrant_RecoveryAfterExpiredMessage()
        {
            List <Task> promises    = new List <Task>();
            TimeSpan    prevTimeout = GrainClient.GetResponseTimeout();

            // set short response time and ask to do long operation, to trigger expired msgs in the silo queues.
            TimeSpan shortTimeout = TimeSpan.FromMilliseconds(1000);

            GrainClient.SetResponseTimeout(shortTimeout);

            ITestGrain grain = GrainClient.GrainFactory.GetGrain <ITestGrain>(GetRandomGrainId());
            int        num   = 10;

            for (long i = 0; i < num; i++)
            {
                Task task = grain.DoLongAction(TimeSpan.FromMilliseconds(shortTimeout.TotalMilliseconds * 3), "A_" + i);
                promises.Add(task);
            }
            try
            {
                Task.WhenAll(promises).Wait();
            }catch (Exception)
            {
                logger.Info("Done with stress iteration.");
            }

            // wait a bit to make sure expired msgs in the silo is trigered.
            Thread.Sleep(TimeSpan.FromSeconds(10));

            // set the regular response time back, expect msgs ot succeed.
            GrainClient.SetResponseTimeout(prevTimeout);

            logger.Info("About to send a next legit request that should succeed.");
            grain.DoLongAction(TimeSpan.FromMilliseconds(1), "B_" + 0).Wait();
            logger.Info("The request succeeded.");
        }