Exemplo n.º 1
0
 public static void Run <TMessage>(IReceivedMessage <TMessage> message, IWorkerNotification notification, Guid queueId, int runTime)
     where TMessage : class
 {
     if (MethodIncrementWrapper.HasRollBack(queueId, (Guid)message.CorrelationId.Id.Value))
     {
         var counter = runTime / 3;
         for (var i = 0; i < counter; i++)
         {
             if (notification.WorkerStopping.StopWorkToken.IsCancellationRequested || notification.WorkerStopping.CancelWorkToken.IsCancellationRequested)
             {
                 MethodIncrementWrapper.IncreaseCounter(queueId);
                 return;
             }
             Thread.Sleep(1000);
         }
         MethodIncrementWrapper.IncreaseCounter(queueId);
     }
     else
     {
         var counter = runTime / 2;
         for (var i = 0; i < counter; i++)
         {
             Thread.Sleep(1000);
         }
         MethodIncrementWrapper.SetRollback(queueId, (Guid)message.CorrelationId.Id.Value);
         throw new OperationCanceledException("I don't feel like processing this message");
     }
 }
Exemplo n.º 2
0
        public static void Run(Guid queueId, int runTime, int counter)
        {
            if (runTime > 0)
            {
                Thread.Sleep(runTime * 1000);
            }

            MethodIncrementWrapper.IncreaseCounter(queueId);
        }
Exemplo n.º 3
0
        public static object RunRpc(Guid queueId, int runTime)
        {
            if (runTime > 0)
            {
                Thread.Sleep(runTime * 1000);
            }

            MethodIncrementWrapper.IncreaseCounter(queueId);

            var rc = new FakeResponse {
                ResponseMessage = "int test"
            };

            return(rc);
        }
Exemplo n.º 4
0
        public static void Run <TMessage>(IReceivedMessage <TMessage> message, Guid queueId, int runTime)
            where TMessage : class
        {
            if (MethodIncrementWrapper.HasRollBack(queueId, (Guid)message.CorrelationId.Id.Value))
            {
                if (runTime > 0)
                {
                    Thread.Sleep(runTime * 1000);
                }

                MethodIncrementWrapper.IncreaseCounter(queueId);
            }
            else
            {
                MethodIncrementWrapper.SetRollback(queueId, (Guid)message.CorrelationId.Id.Value);
                throw new OperationCanceledException("I don't feel like processing this message");
            }
        }
Exemplo n.º 5
0
 public void HandleExecution(IReceivedMessage <MessageExpression> receivedMessage,
                             IWorkerNotification notification)
 {
     MethodIncrementWrapper.SetRollback(_queueId, (Guid)receivedMessage.CorrelationId.Id.Value);
     throw new OperationCanceledException("I don't feel like processing this message");
 }
Exemplo n.º 6
0
 public static void Clear(Guid queueId)
 {
     MethodIncrementWrapper.Clear(queueId);
 }