internal void DropOrRejectReceivedMessage(MsmqQueue queue, MsmqMessageProperty messageProperty, bool reject)
 {
     if (this.Transactional)
     {
         TryAbortTransactionCurrent();
         IPostRollbackErrorStrategy  strategy = new SimplePostRollbackErrorStrategy(messageProperty.LookupId);
         MsmqQueue.MoveReceiveResult unknown  = MsmqQueue.MoveReceiveResult.Unknown;
         do
         {
             using (MsmqEmptyMessage message = new MsmqEmptyMessage())
             {
                 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                 {
                     unknown = queue.TryReceiveByLookupId(messageProperty.LookupId, message, MsmqTransactionMode.CurrentOrThrow);
                     if ((MsmqQueue.MoveReceiveResult.Succeeded == unknown) && reject)
                     {
                         queue.MarkMessageRejected(messageProperty.LookupId);
                     }
                     scope.Complete();
                 }
             }
             if (unknown == MsmqQueue.MoveReceiveResult.Succeeded)
             {
                 MsmqDiagnostics.MessageConsumed(this.instanceId, messageProperty.MessageId, Msmq.IsRejectMessageSupported && reject);
             }
         }while ((unknown == MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction) && strategy.AnotherTryNeeded());
     }
     else
     {
         MsmqDiagnostics.MessageConsumed(this.instanceId, messageProperty.MessageId, false);
     }
 }
 internal void DropOrRejectReceivedMessage(MsmqQueue queue, MsmqMessageProperty messageProperty, bool reject)
 {
     if (this.Transactional)
     {
         TryAbortTransactionCurrent();
         IPostRollbackErrorStrategy strategy = new SimplePostRollbackErrorStrategy(messageProperty.LookupId);
         MsmqQueue.MoveReceiveResult unknown = MsmqQueue.MoveReceiveResult.Unknown;
         do
         {
             using (MsmqEmptyMessage message = new MsmqEmptyMessage())
             {
                 using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                 {
                     unknown = queue.TryReceiveByLookupId(messageProperty.LookupId, message, MsmqTransactionMode.CurrentOrThrow);
                     if ((MsmqQueue.MoveReceiveResult.Succeeded == unknown) && reject)
                     {
                         queue.MarkMessageRejected(messageProperty.LookupId);
                     }
                     scope.Complete();
                 }
             }
             if (unknown == MsmqQueue.MoveReceiveResult.Succeeded)
             {
                 MsmqDiagnostics.MessageConsumed(this.instanceId, messageProperty.MessageId, Msmq.IsRejectMessageSupported && reject);
             }
         }
         while ((unknown == MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction) && strategy.AnotherTryNeeded());
     }
     else
     {
         MsmqDiagnostics.MessageConsumed(this.instanceId, messageProperty.MessageId, false);
     }
 }
Esempio n. 3
0
        internal void DropOrRejectReceivedMessage(MsmqQueue queue, MsmqMessageProperty messageProperty, bool reject)
        {
            if (this.Transactional)
            {
                TryAbortTransactionCurrent();
                IPostRollbackErrorStrategy  postRollback = new SimplePostRollbackErrorStrategy(messageProperty.LookupId);
                MsmqQueue.MoveReceiveResult result       = MsmqQueue.MoveReceiveResult.Unknown;
                do
                {
                    using (MsmqEmptyMessage emptyMessage = new MsmqEmptyMessage())
                    {
                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                        {
                            result = queue.TryReceiveByLookupId(messageProperty.LookupId, emptyMessage, MsmqTransactionMode.CurrentOrThrow);
                            if (MsmqQueue.MoveReceiveResult.Succeeded == result && reject)
                            {
                                queue.MarkMessageRejected(messageProperty.LookupId);
                            }
                            scope.Complete();
                        }
                    }

                    if (result == MsmqQueue.MoveReceiveResult.Succeeded)
                    {
                        // If 'Reject' supported and 'Reject' requested, put reject in the trace, otherwise put 'Drop'
                        MsmqDiagnostics.MessageConsumed(instanceId, messageProperty.MessageId, (Msmq.IsRejectMessageSupported && reject));
                    }

                    if (result != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                    {
                        break;
                    }
                }while (postRollback.AnotherTryNeeded());
            }
            else
            {
                MsmqDiagnostics.MessageConsumed(instanceId, messageProperty.MessageId, false);
            }
        }
        internal void DropOrRejectReceivedMessage(MsmqQueue queue, MsmqMessageProperty messageProperty, bool reject)
        {
            if (this.Transactional)
            {
                TryAbortTransactionCurrent();
                IPostRollbackErrorStrategy postRollback = new SimplePostRollbackErrorStrategy(messageProperty.LookupId);
                MsmqQueue.MoveReceiveResult result = MsmqQueue.MoveReceiveResult.Unknown;
                do
                {
                    using (MsmqEmptyMessage emptyMessage = new MsmqEmptyMessage())
                    {
                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                        {
                            result = queue.TryReceiveByLookupId(messageProperty.LookupId, emptyMessage, MsmqTransactionMode.CurrentOrThrow);
                            if (MsmqQueue.MoveReceiveResult.Succeeded == result && reject)
                                queue.MarkMessageRejected(messageProperty.LookupId);
                            scope.Complete();
                        }
                    }

                    if (result == MsmqQueue.MoveReceiveResult.Succeeded)
                        // If 'Reject' supported and 'Reject' requested, put reject in the trace, otherwise put 'Drop'
                        MsmqDiagnostics.MessageConsumed(instanceId, messageProperty.MessageId, (Msmq.IsRejectMessageSupported && reject));

                    if (result != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                        break;
                }
                while (postRollback.AnotherTryNeeded());
            }
            else
            {
                MsmqDiagnostics.MessageConsumed(instanceId, messageProperty.MessageId, false);
            }
        }