예제 #1
0
        public void UnlockMessage(long lookupId, TimeSpan timeout)
        {
            MoveReceiveResult          moveResult;
            IPostRollbackErrorStrategy postRollBack = new SimplePostRollbackErrorStrategy(lookupId);

            do
            {
                moveResult = this.lockQueueForReceive.TryMoveMessage(lookupId, this.mainQueueForMove, MsmqTransactionMode.None);
                if (moveResult != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                {
                    break;
                }

                // We could have failed because of ---- with transaction.abort() for the transaction
                // that had this message locked previously. We will retry in these cases.
            } while (postRollBack.AnotherTryNeeded());

            if (moveResult != MoveReceiveResult.Succeeded)
            {
                // We could have failed because of
                //  a) failure in the underlying queue manager
                //  b) expiration of the native message timer
                //  c) ---- with Channel.Close()
                // ..not much we can do in any of these cases

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqReceiveContextMessageNotMoved, lookupId.ToString(CultureInfo.InvariantCulture))));
            }
        }
 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);
     }
 }
예제 #3
0
        public void DeleteMessage(long lookupId, TimeSpan timeout)
        {
            // operations on the lock subqueue need to be protected from ---- with close
            MoveReceiveResult          receiveResult;
            IPostRollbackErrorStrategy postRollBack = new SimplePostRollbackErrorStrategy(lookupId);

            do
            {
                using (MsmqEmptyMessage emptyMessage = new MsmqEmptyMessage())
                {
                    receiveResult = this.lockQueueForReceive.TryReceiveByLookupId(lookupId, emptyMessage, MsmqTransactionMode.CurrentOrNone);
                }

                if (receiveResult != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                {
                    break;
                }

                // We could have failed because of ---- with transaction.abort() for the transaction
                // that had this message locked previously. We will retry in these cases.
            } while (postRollBack.AnotherTryNeeded());

            // We could have failed because of
            //  a) failure in the underlying queue manager
            //  b) expiration of the native message timer
            //  c) ---- with Channel.Close()
            // ..not much we can do in any of these cases
            if (receiveResult != MoveReceiveResult.Succeeded)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqReceiveContextMessageNotReceived, lookupId.ToString(CultureInfo.InvariantCulture))));
            }
        }
 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 static void MoveReceivedMessage(MsmqQueue queueFrom, MsmqQueue queueTo, long lookupId)
        {
            TryAbortTransactionCurrent();
            IPostRollbackErrorStrategy strategy = new SimplePostRollbackErrorStrategy(lookupId);

            do
            {
                if (queueFrom.TryMoveMessage(lookupId, queueTo, MsmqTransactionMode.Single) != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                {
                    return;
                }
            }while (strategy.AnotherTryNeeded());
        }
예제 #6
0
        public void UnlockMessage(long lookupId, TimeSpan timeout)
        {
            MsmqQueue.MoveReceiveResult result;
            IPostRollbackErrorStrategy  strategy = new SimplePostRollbackErrorStrategy(lookupId);

            do
            {
                result = this.lockQueueForReceive.TryMoveMessage(lookupId, this.mainQueueForMove, MsmqTransactionMode.None);
            }while ((result == MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction) && strategy.AnotherTryNeeded());
            if (result != MsmqQueue.MoveReceiveResult.Succeeded)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(System.ServiceModel.SR.GetString("MsmqReceiveContextMessageNotMoved", new object[] { lookupId.ToString(CultureInfo.InvariantCulture) })));
            }
        }
예제 #7
0
        //
        internal static void MoveReceivedMessage(MsmqQueue queueFrom, MsmqQueue queueTo, long lookupId)
        {
            TryAbortTransactionCurrent();

            IPostRollbackErrorStrategy postRollback = new SimplePostRollbackErrorStrategy(lookupId);

            MsmqQueue.MoveReceiveResult result = MsmqQueue.MoveReceiveResult.Unknown;
            do
            {
                result = queueFrom.TryMoveMessage(lookupId, queueTo, MsmqTransactionMode.Single);

                if (result != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                {
                    break;
                }
            }while (postRollback.AnotherTryNeeded());
        }
예제 #8
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);
            }
        }
 public void DeleteMessage(long lookupId, TimeSpan timeout)
 {
     MsmqQueue.MoveReceiveResult result;
     IPostRollbackErrorStrategy strategy = new SimplePostRollbackErrorStrategy(lookupId);
     do
     {
         using (MsmqEmptyMessage message = new MsmqEmptyMessage())
         {
             result = this.lockQueueForReceive.TryReceiveByLookupId(lookupId, message, MsmqTransactionMode.CurrentOrNone);
         }
     }
     while ((result == MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction) && strategy.AnotherTryNeeded());
     if (result != MsmqQueue.MoveReceiveResult.Succeeded)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(System.ServiceModel.SR.GetString("MsmqReceiveContextMessageNotReceived", new object[] { lookupId.ToString(CultureInfo.InvariantCulture) })));
     }
 }
        //
        internal static void MoveReceivedMessage(MsmqQueue queueFrom, MsmqQueue queueTo, long lookupId)
        {
            TryAbortTransactionCurrent();

            IPostRollbackErrorStrategy postRollback = new SimplePostRollbackErrorStrategy(lookupId);
            MsmqQueue.MoveReceiveResult result = MsmqQueue.MoveReceiveResult.Unknown;
            do
            {
                result = queueFrom.TryMoveMessage(lookupId, queueTo, MsmqTransactionMode.Single);

                if (result != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                    break;
            }
            while (postRollback.AnotherTryNeeded());
        }
        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);
            }
        }
        public void UnlockMessage(long lookupId, TimeSpan timeout)
        {
            MoveReceiveResult moveResult;
            IPostRollbackErrorStrategy postRollBack = new SimplePostRollbackErrorStrategy(lookupId);
            do
            {
                moveResult = this.lockQueueForReceive.TryMoveMessage(lookupId, this.mainQueueForMove, MsmqTransactionMode.None);
                if (moveResult != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                    break;

                // We could have failed because of ---- with transaction.abort() for the transaction 
                // that had this message locked previously. We will retry in these cases.
            } while (postRollBack.AnotherTryNeeded());

            if (moveResult != MoveReceiveResult.Succeeded)
            {
                // We could have failed because of
                //  a) failure in the underlying queue manager
                //  b) expiration of the native message timer
                //  c) ---- with Channel.Close()
                // ..not much we can do in any of these cases

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqReceiveContextMessageNotMoved, lookupId.ToString(CultureInfo.InvariantCulture))));
            }
        }
        public void DeleteMessage(long lookupId, TimeSpan timeout)
        {
            // operations on the lock subqueue need to be protected from ---- with close
            MoveReceiveResult receiveResult;
            IPostRollbackErrorStrategy postRollBack = new SimplePostRollbackErrorStrategy(lookupId);
            do
            {
                using (MsmqEmptyMessage emptyMessage = new MsmqEmptyMessage())
                {
                    receiveResult = this.lockQueueForReceive.TryReceiveByLookupId(lookupId, emptyMessage, MsmqTransactionMode.CurrentOrNone);
                }

                if (receiveResult != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
                    break;

                // We could have failed because of ---- with transaction.abort() for the transaction 
                // that had this message locked previously. We will retry in these cases.
            } while (postRollBack.AnotherTryNeeded());

            // We could have failed because of
            //  a) failure in the underlying queue manager
            //  b) expiration of the native message timer
            //  c) ---- with Channel.Close()
            // ..not much we can do in any of these cases
            if (receiveResult != MoveReceiveResult.Succeeded)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MsmqException(SR.GetString(SR.MsmqReceiveContextMessageNotReceived, lookupId.ToString(CultureInfo.InvariantCulture))));
            }
        }
 internal static void MoveReceivedMessage(MsmqQueue queueFrom, MsmqQueue queueTo, long lookupId)
 {
     TryAbortTransactionCurrent();
     IPostRollbackErrorStrategy strategy = new SimplePostRollbackErrorStrategy(lookupId);
     do
     {
         if (queueFrom.TryMoveMessage(lookupId, queueTo, MsmqTransactionMode.Single) != MsmqQueue.MoveReceiveResult.MessageLockedUnderTransaction)
         {
             return;
         }
     }
     while (strategy.AnotherTryNeeded());
 }