private void DispatchLocal(MessageContainer mc, DeliveryMode dm)
        {
            var pm = _currentMessage;
            var mb = MessageBusContext.CurrentMessageBus;

            try
            {
                _currentMessage = new CurMsg(mc);
                MessageBusContext.CurrentMessageBus = this;
                _currentMessage.DeliveryMode        = dm;
                Dispatcher.DispatchMessage(mc.Body, this);
            }
            catch (Exception ex)
            {
                log.Warn("Error async processing message {0}: {1}", mc.BusMessageId, ex.ToString());
                if (dm != DeliveryMode.LocalAsync)
                {
                    throw;
                }
            }
            finally
            {
                _currentMessage = pm;
                MessageBusContext.CurrentMessageBus = mb;
            }
        }
 /// <summary>
 /// Deliver the message to handlers
 /// </summary>
 /// <param name="mc"></param>
 protected virtual void DispatchIncomingMessage(MessageContainer mc)
 {
     log.Debug("MB {2} Dispatching incoming message {0}/{1}/{3}", mc.To, mc.BusMessageId, this.Endpoint, mc.Body.GetType().Name);
     try
     {
         MessageBusContext.CurrentMessageBus = this;
         _currentMessage = new CurMsg(mc);
         if (UseTransactionScope && Transaction.Current == null)
         {
             TransactionOptions to = new TransactionOptions();
             to.IsolationLevel = IsolationLevel.ReadCommitted;
             to.Timeout        = TimeSpan.FromSeconds(30);
             TransactionScopeOption tso = MessageHandlerTransactionScopeOption;
             using (TransactionScope ts = new TransactionScope(tso, to))
             {
                 Dispatcher.DispatchMessage(mc.Body, this);
                 ts.Complete();
             }
         }
         else
         {
             Dispatcher.DispatchMessage(mc.Body, this);
         }
     }
     finally
     {
         _currentMessage = null;
         MessageBusContext.CurrentMessageBus = null;
     }
 }
 private void DispatchLocal(MessageContainer mc, DeliveryMode dm)
 {
     var pm = _currentMessage;
     var mb = MessageBusContext.CurrentMessageBus;
     try
     {
         _currentMessage = new CurMsg(mc);
         MessageBusContext.CurrentMessageBus = this;
         _currentMessage.DeliveryMode = dm;
         Dispatcher.DispatchMessage(mc.Body, this);
     }
     catch (Exception ex)
     {
         log.Warn("Error async processing message {0}: {1}", mc.BusMessageId, ex.ToString());
         if (dm != DeliveryMode.LocalAsync)
         {
             throw;
         }
     }
     finally
     {
         _currentMessage = pm;
         MessageBusContext.CurrentMessageBus = mb;
     }
 }
 /// <summary>
 /// Deliver the message to handlers
 /// </summary>
 /// <param name="mc"></param>
 protected virtual void DispatchIncomingMessage(MessageContainer mc)
 {
     log.Debug("MB {2} Dispatching incoming message {0}/{1}/{3}", mc.To, mc.BusMessageId, this.Endpoint, mc.Body.GetType().Name);
     try
     {
         MessageBusContext.CurrentMessageBus = this;
         _currentMessage = new CurMsg(mc);
         if (UseTransactionScope && Transaction.Current == null)
         {
             TransactionOptions to = new TransactionOptions();
             to.IsolationLevel = IsolationLevel.ReadCommitted;
             to.Timeout = TimeSpan.FromSeconds(30);
             TransactionScopeOption tso = MessageHandlerTransactionScopeOption;
             using (TransactionScope ts = new TransactionScope(tso, to))
             {
                 Dispatcher.DispatchMessage(mc.Body, this);
                 ts.Complete();
             }
         }
         else
         {
             Dispatcher.DispatchMessage(mc.Body, this);
         }
     }
     finally
     {
         _currentMessage = null;
         MessageBusContext.CurrentMessageBus = null;
     }
 }