Exemple #1
0
        /// <summary>
        /// OK - here's how stuff is nested:
        ///
        /// - Message queue transaction (TxBomkarl)
        ///     - Before/After transport message
        ///         - TransactionScope
        ///             - Before/After logical message
        ///                 Dispatch logical message
        /// </summary>
        void TryProcessIncomingMessage()
        {
            using (var context = new TxBomkarl())
            {
                try
                {
                    DoTry();

                    try
                    {
                        context.RaiseDoCommit();
                    }
                    catch (Exception commitException)
                    {
                        throw new QueueCommitException(commitException);
                    }
                }
                catch
                {
                    try
                    {
                        context.RaiseDoRollback();
                    }
                    catch (Exception e)
                    {
                        log.Error(e, "An error occurred while rolling back the transaction!");
                    }

                    throw;
                }
            }
        }
        public void CanCreateAutoDeleteQueue()
        {
            const string queueName = "test.autodelete.input";
            DeleteQueue(queueName);

            // arrange
            var existedBeforeInstatiation = QueueExists(queueName);
            bool existedWhileInstantiatedAndInsideTx;
            bool existedWhileInstantiatedAndOutsideOfTx;

            // act
            using (var queue = new RabbitMqMessageQueue(ConnectionString, queueName).AutoDeleteInputQueue())
            {
                using (var scope = new TransactionScope())
                {
                    using (var txBomkarl = new TxBomkarl())
                    {
                        var willBeNull = queue.ReceiveMessage(txBomkarl);

                        existedWhileInstantiatedAndInsideTx = QueueExists(queueName);
                    }

                    existedWhileInstantiatedAndOutsideOfTx = QueueExists(queueName);
                }
            }

            var existedAfterDisposal = QueueExists(queueName);

            // assert
            existedBeforeInstatiation.ShouldBe(false);
            existedWhileInstantiatedAndInsideTx.ShouldBe(true);
            existedWhileInstantiatedAndOutsideOfTx.ShouldBe(true);
            existedAfterDisposal.ShouldBe(false);
        }
Exemple #3
0
 /// <summary>
 /// OK - here's how stuff is nested:
 ///
 /// - Message queue transaction (TxBomkarl)
 ///     - Before/After transport message
 ///         - TransactionScope
 ///             - Before/After logical message
 ///                 Dispatch logical message
 /// </summary>
 void TryProcessIncomingMessage()
 {
     using (var context = new TxBomkarl())
     {
         try
         {
             DoTry();
             context.RaiseDoCommit();
         }
         catch
         {
             context.RaiseDoRollback();
             throw;
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// OK - here's how stuff is nested:
        /// 
        /// - Message queue transaction (TxBomkarl)
        ///     - Before/After transport message
        ///         - TransactionScope
        ///             - Before/After logical message
        ///                 Dispatch logical message
        /// </summary>
        async void TryProcessIncomingMessage()
        {
            using (var context = new TxBomkarl())
            {
                try
                {
                    await DoTry();

                    try
                    {
                        context.RaiseDoCommit();
                    }
                    catch (Exception commitException)
                    {
                        throw new QueueCommitException(commitException);
                    }
                }
                catch
                {
                    try
                    {
                        context.RaiseDoRollback();
                    }
                    catch (Exception e)
                    {
                        log.Error(e, "An error occurred while rolling back the transaction!");
                    }

                    throw;
                }
            }
        }