public void ReturnMessageToSourceQueue(string fromQueueName, ServiceBusMQ.Model.QueueItem itm)
        {
            var queue           = QueueClient.CreateFromConnectionString(ConnectionString, fromQueueName);
            var deadLetterQueue = QueueClient.CreateFromConnectionString(ConnectionString, QueueClient.FormatDeadLetterPath(fromQueueName), ReceiveMode.ReceiveAndDelete);

            ReturnMessageToSourceQueue(queue, deadLetterQueue, itm);
        }
		public void LoadMessageContent(QueueItem itm)
		{
			Message msg = null;

			if (!itm.Processed)
			{
				try
				{
					msg = _mainContent.PeekById(itm.Id);

				}
				catch
				{

					if (_journalContent != null)
					{
						try
						{
							msg = _journalContent.ReceiveById(itm.Id);

						}
						catch
						{
							itm.Content = "**MESSAGE HAS BEEN PROCESSED OR PURGED**";
						}

					}
					else itm.Content = "**MESSAGE HAS BEEN PROCESSED OR PURGED AND JOURNALING IS TURNED OFF**";

				}
			}
			else
			{

				if (_journalContent != null)
				{

					try
					{
						msg = _journalContent.ReceiveById(itm.Id);
					}
					catch
					{
						itm.Content = "**MESSAGE HAS BEEN PURGED FROM JOURNAL**";
					}

				}
				else
				{
					itm.Content = "**MESSAGE HAS BEEN PROCESSED OR PURGED AND JOURNALING IS TURNED OFF**";
				}

			}

			if (msg != null)
				itm.Content = ReadMessageStream(msg.BodyStream);
		}
        public QueueItemViewModel(QueueItem item)
            : base(item.Queue)
        {
            MapQueueItem(item);

              BindImage();

              if( ArrivedTime.Date == DateTime.Today.Date )
            ArrivedTimeString = ArrivedTime.ToString("HH:mm:ss");
              else ArrivedTimeString = "{1} {0} - {2}".With(Tools.MONTH_NAMES_ABBR[ArrivedTime.Month - 1],
                                                      ArrivedTime.Day,
                                                      ArrivedTime.ToString("HH:mm:ss"));

              SetTextWidth();
        }
        public void ReturnAll(string fromQueueName)
        {
            var queue = GetInputQueue(fromQueueName);

              foreach( var msg in queue.ReceiveBatch(0xFFFF) ) {

            var itm = new QueueItem(null);
            itm.MessageQueueItemId = msg.SequenceNumber;

            itm.Headers = new Dictionary<string, string>();
            if( msg.Properties.Count > 0 )
              msg.Properties.ForEach(p => itm.Headers.Add(p.Key, p.Value.ToString()));

            ReturnMessageToSourceQueue(queue, itm);
              }
        }
    public void MoveErrorMessageToOriginQueue(QueueItem itm) {
      if( string.IsNullOrEmpty(itm.Id) )
        throw new ArgumentException("MessageId can not be null or empty");

      if( itm.Queue.Type != QueueType.Error )
        throw new ArgumentException("Queue is not of type Error, " + itm.Queue.Type);

      var mgr = new ErrorManager();

      // TODO:
      // Check if Clustered Queue, due if Clustered && NonTransactional, then Error

      mgr.InputQueue = Address.Parse(itm.Queue.Name);

      mgr.ReturnMessageToSourceQueue(itm.Id);
    }
    private void MapQueueItem(QueueItem item) {
      Id = item.Id;
      MessageQueueItemId = item.MessageQueueItemId;
      DisplayName = item.DisplayName;
      Messages = item.Messages;
      OriginQueueName = item.OriginQueueName;

      ArrivedTime = item.ArrivedTime;
      ProcessTime = item.ProcessTime;
      Processed = item.Processed;

      Content = item.Content;

      Headers = item.Headers;

      Error = item.Error;
    }
        /// <summary>
        ///     May throw a timeout exception if a message with the given id cannot be found.
        /// </summary>
        /// <param name="seqNumber"></param>
        public void ReturnMessageToSourceQueue(QueueClient queue, ServiceBusMQ.Model.QueueItem itm)
        {
            try {
                var msg = FindMessage(queue, itm); //queue.Receive((long)itm.MessageQueueItemId);

                string originQueueName = GetOriginQueue(msg);
                if (originQueueName.IsValid())
                {
                    var q = GetInputQueue(originQueueName);
                    q.Send(msg.Clone());

                    msg.Complete();
                }
                else
                {
                    _log.Trace("No valid origin Queue for Message, " + itm.Id);
                }
            } catch (Exception ex) {
                _log.Trace(ex.ToString());
            }
        }
        private string GetOriginQueue(ServiceBusMQ.Model.QueueItem msg)
        {
            var name = string.Empty;

            if (msg.Headers.ContainsKey(KEY_FailedQueue))
            {
                name = msg.Headers[KEY_FailedQueue] as string;
            }

            if (!string.IsNullOrEmpty(name))
            {
                var i = name.IndexOf('@');

                if (i > 0)
                {
                    name = name.Substring(0, i);
                }
            }

            return(name);
        }
        public QueueItemViewModel(QueueItem item, bool showMilliSeconds)
            : base(item.Queue)
        {
            MapQueueItem(item);

              BindImage();

              if( ArrivedTime.Date == DateTime.Today.Date )
            ArrivedTimeString = ArrivedTime.ToString("HH:mm:ss");
              else {
            string year = ArrivedTime.Year != DateTime.Today.Year ? string.Concat(ArrivedTime.Year,' ') : string.Empty;

            ArrivedTimeString = "{1} {0} {3}- {2}".With(Tools.MONTH_NAMES_ABBR[ArrivedTime.Month - 1],
                                                      ArrivedTime.Day,
                                                      ArrivedTime.ToString("HH:mm:ss"),
                                                      year);
              }

              if( showMilliSeconds )
            ArrivedTimeMSString = ArrivedTime.ToString(".fff");

              SetTextWidth();
        }
        private void TryFindMessage(ServiceBusMQ.Model.QueueItem itm)
        {
            //if( ex.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout ) {

            //  foreach( var m in queue.GetAllMessages() ) {
            //    var tm = MsmqUtilities.Convert(m);

            //    string originalId = null;

            //    if( tm.Headers.ContainsKey(Headers.MessageId) ) {
            //      originalId = tm.Headers[Headers.MessageId];
            //    }

            //    if( string.IsNullOrEmpty(originalId) && tm.Headers.ContainsKey(Headers.CorrelationId) ) {
            //      originalId = tm.Headers[Headers.CorrelationId];
            //    }

            //    if( string.IsNullOrEmpty(originalId) || seqNumber != originalId ) {
            //      continue;
            //    }

            //    Console.WriteLine("Found message - going to return to queue.");

            //    using( var q = GetInputQueue(itm.Headers[FaultsHeaderKeys.FailedQ]) ) {
            //      q.Send(m);
            //    }

            //    queue.ReceiveByLookupId(MessageLookupAction.Current, m.LookupId,
            //        MessageQueueTransactionType.Automatic);

            //  }

            //  Console.WriteLine("Success.");

            //  return;
            //}
        }
Example #11
0
        /// <summary>
        ///     May throw a timeout exception if a message with the given id cannot be found.
        /// </summary>
        /// <param name="seqNumber"></param>
        public void ReturnMessageToSourceQueue(QueueClient queue, ServiceBusMQ.Model.QueueItem itm)
        {
            try {
                var message = queue.Receive((long)itm.MessageQueueItemId);

                string failedQ = null;
                if (itm.Headers.ContainsKey(KEY_FailedQueue))
                {
                    failedQ = itm.Headers[KEY_FailedQueue];
                }

                if (string.IsNullOrEmpty(failedQ))
                {
                    Console.WriteLine("ERROR: Message does not have a header indicating from which queue it came. Cannot be automatically returned to queue.");
                    return;
                }

                var q = GetInputQueue(failedQ);
                q.Send(message);
            } catch (Exception ex) {
                //} catch( MessageQueueException ex ) {
                TryFindMessage(itm);
            }
        }
Example #12
0
 internal void ReturnMessageToSourceQueue(QueueItem itm) {
 }
        private string GetQueueItemContent(QueueItem itm)
        {
            var content = string.Empty;

              if( itm.Content == null || itm.Content.StartsWith("**") )
            content = _mgr.LoadMessageContent(itm);
              else
            content = itm.Content;

              if( content != null && !itm.Content.StartsWith("**") ) {

            if( itm.Queue.ContentFormat == MessageContentFormat.Unknown ) {
              itm.Queue.SetContentFormat(content);
            }
              }

              return content;
        }
        private void UpdateContextMenu(QueueItem itm)
        {
            var items = lbItems.ContextMenu.Items;

              // Copy to Clipboard
              _BindContextMenuItem(miCopyMsgId, itm);
              _BindContextMenuItem(miCopyMsgName, itm);
              _BindContextMenuItem(miCopyMsgContent, itm);
              _BindContextMenuItem(miResendCommand, itm, qi => _sys.CanSendCommand && qi.Queue.Type == QueueType.Command);

              if( itm != null )
            miReturnErrToOrgin.FontWeight = itm.Queue.Type == QueueType.Error ? FontWeights.Bold : FontWeights.Normal;

              // Remove message
              _BindContextMenuItem(miPurgeMsg, itm, qi => !qi.Processed && HasFeature(ServiceBusFeature.PurgeMessage));

              // Return Error Message to Origin
              _BindContextMenuItem(miReturnErrToOrgin, itm, qi => qi.Queue.Type == QueueType.Error && HasFeature(ServiceBusFeature.MoveErrorMessageToOriginQueue));

            #if DEBUG
              MenuItem mi = null;
              if( ( ( items[items.Count - 1] as MenuItem ).Header as string ) != "Headers" ) {
            mi = new MenuItem();
            mi.Header = "Headers";
            items.Add(mi);

              } else mi = (MenuItem)items[items.Count - 1];

              mi.Items.Clear();

              if( itm != null && itm.Headers != null )
            foreach( var head in itm.Headers )
              mi.Items.Add(new MenuItem() { Header = string.Concat(head.Key, '=', head.Value) });
            #endif
        }
        public void PurgeMessage(QueueItem itm)
        {
            MessageQueue q = GetMessageQueue(itm);

            if (q != null)
            {
                q.ReceiveById(itm.Id);

                itm.Processed = true;

                OnItemsChanged();
            }
        }
        public string LoadMessageContent(QueueItem itm)
        {
            if (itm.Content == null)
            {

                MsmqMessageQueue msmq = GetMessageQueue(itm);

                msmq.LoadMessageContent(itm);
            }

            return itm.Content;
        }
        private bool PrepareQueueItemForAdd(QueueItem itm)
        {

            // Get from Message body
            if (itm.Content == null)
                LoadMessageContent(itm);

            itm.Messages = GetMessageNames(itm.Content, false);

            itm.DisplayName = MergeStringArray(itm.Messages).Default(itm.DisplayName).CutEnd(55);

            return true;
        }
 public abstract void PurgeMessage(QueueItem itm);
        /// <summary>
        /// Called when we know that we actually shall add the item, and here we can execute processes that takes extra time
        /// </summary>
        /// <param name="itm"></param>
        /// <returns></returns>
        private bool PrepareQueueItemForAdd(QueueItem itm)
        {
            // Ignore control messages
              //if( itm.Headers.ContainsKey(Headers.ControlMessageHeader) && Convert.ToBoolean(itm.Headers[Headers.ControlMessageHeader]) )
              //  return false;

              if( itm.Headers.ContainsKey("NServiceBus.MessageId") )
            itm.Id = itm.Headers["NServiceBus.MessageId"];

              // Get Messages names
              if( itm.Headers.ContainsKey("NServiceBus.EnclosedMessageTypes") ) {
            itm.Messages = ExtractEnclosedMessageTypeNames(itm.Headers["NServiceBus.EnclosedMessageTypes"]);

              } else { // Get from Message body
            if( itm.Content == null )
              LoadMessageContent(itm);

            itm.Messages = GetMessageNames(itm.Content, false);
              }
              itm.DisplayName = MergeStringArray(itm.Messages).Default(itm.DisplayName).CutEnd(55);

              // Get process started time
              if( itm.Headers.ContainsKey("NServiceBus.ProcessingStarted") && itm.Headers.ContainsKey("NServiceBus.ProcessingEnded") ) {

            try {
              itm.ProcessTime = Convert.ToInt32(( Convert.ToDateTime(itm.Headers["NServiceBus.ProcessingEnded"]) -
                            Convert.ToDateTime(itm.Headers["NServiceBus.ProcessingStarted"]) ).TotalSeconds);

            } catch( Exception ex ) {
            #if DEBUG
              Console.WriteLine("Failed to parse NServiceBus.ProcessingStarted, " + ex.Message);
            #endif
            }

              }

              // Get Error message info
              itm.Error = null; //new QueueItemError();

              return true;
        }
        private QueueItem CreateQueueItem(Queue queue, BrokeredMessage msg)
        {
            var itm = new QueueItem(queue);
              itm.DisplayName = msg.Label;
              itm.MessageQueueItemId = msg.SequenceNumber;
              itm.Id = msg.SequenceNumber.ToString(); //msg.MessageId;
              itm.ArrivedTime = msg.EnqueuedTimeUtc;
              try {
            itm.Content = ReadMessageStream(new System.IO.MemoryStream(msg.GetBody<byte[]>()));

              } catch( SerializationException ex ) {
            itm.Content = "** Failed to get message content, {0} ** \n\n{1}".With(ex.Message, ex.StackTrace);
            //itm.Error = new QueueItemError() {
            //  Message = ex.Message,
            //  StackTrace = ex.StackTrace,
            //  State = QueueItemErrorState.Retry
            //};
              }
              //itm.Content = ReadMessageStream(msg.BodyStream);

              itm.Headers = new Dictionary<string, string>();
              if( msg.Properties.Count > 0 )
            msg.Properties.ForEach(p => itm.Headers.Add(p.Key, p.Value.ToString()));

              return itm;
        }
Example #21
0
    private BrokeredMessage FindMessage(QueueClient client, QueueItem msg) {

      var items = client.PeekBatch(50);
      while( items != null && items.Any() ) {
        foreach( var itm in items ) {
          if( itm.MessageId == msg.Id )
            return itm;
        }

        items = client.PeekBatch(50);
      }

      return null;
    }
        private QueueItem CreateQueueItem(Queue queue, Message msg)
        {
            var itm = new QueueItem(queue);
              itm.DisplayName = msg.Label;
              itm.Id = msg.Id;
              itm.ArrivedTime = msg.ArrivedTime;
              //itm.Content = ReadMessageStream(msg.BodyStream);

              itm.Headers = new Dictionary<string, string>();
              if( msg.Extension.Length > 0 ) {
            var stream = new MemoryStream(msg.Extension);
            var o = headerSerializer.Deserialize(stream);

            foreach( var pair in o as List<HeaderInfo> )
              if( pair.Key != null )
            itm.Headers.Add(pair.Key, pair.Value);
              }

              return itm;
        }
        public void ReturnMessageToSourceQueue(string fromQueueName, ServiceBusMQ.Model.QueueItem itm)
        {
            var queue = GetInputQueue(fromQueueName);

            ReturnMessageToSourceQueue(queue, itm);
        }
        /// <summary>
        /// Called when we know that we actually shall add the item, and here we can execute processes that takes extra time
        /// </summary>
        /// <param name="itm"></param>
        /// <returns></returns>
        private bool PrepareQueueItemForAdd(QueueItem itm)
        {
            // Ignore control messages
              if( itm.Headers.ContainsKey(Headers.ControlMessageHeader) && Convert.ToBoolean(itm.Headers[Headers.ControlMessageHeader]) )
            return false;

              // Get Messages names
              if( itm.Headers.ContainsKey("NServiceBus.EnclosedMessageTypes") ) {
            itm.Messages = ExtractEnclosedMessageTypeNames(itm.Headers["NServiceBus.EnclosedMessageTypes"]);

              } else { // Get from Message body
            if( itm.Content == null )
              LoadMessageContent(itm);

            itm.Messages = GetMessageNames(itm.Content, false);
              }
              itm.DisplayName = MergeStringArray(itm.Messages).Default(itm.DisplayName).CutEnd(55);

              // Get process started time
              if( itm.Headers.ContainsKey("NServiceBus.ProcessingStarted") && itm.Headers.ContainsKey("NServiceBus.ProcessingEnded") ) {

            try {
              itm.ProcessTime = Convert.ToInt32(( Convert.ToDateTime(itm.Headers["NServiceBus.ProcessingEnded"]) -
                            Convert.ToDateTime(itm.Headers["NServiceBus.ProcessingStarted"]) ).TotalSeconds);

            } catch {
            #if DEBUG
              Console.WriteLine("Failed to parse NServiceBus.ProcessingStarted");
            #endif
            }

              }

              // Get Error message info
              if( itm.Headers.ContainsKey("NServiceBus.ExceptionInfo.Message") ) {

            itm.Error = new QueueItemError();
            try {
              itm.Error.State = itm.Queue.Type == QueueType.Error ? QueueItemErrorState.ErrorQueue : QueueItemErrorState.Retry;
              itm.Error.Message = itm.Headers["NServiceBus.ExceptionInfo.Message"];

              if( itm.Headers.ContainsKey("NServiceBus.ExceptionInfo.StackTrace") )
            itm.Error.StackTrace = itm.Headers["NServiceBus.ExceptionInfo.StackTrace"];

              if( itm.Headers.ContainsKey(Headers.Retries) )
            itm.Error.Retries = Convert.ToInt32(itm.Headers[Headers.Retries]);

              //itm.Error.TimeOfFailure = Convert.ToDateTime(itm.Headers.SingleOrDefault(k => k.Key == "NServiceBus.TimeOfFailure").Value);
            } catch {
              itm.Error = null;
            }
              }

              return true;
        }
 private MsmqMessageQueue GetMessageQueue(QueueItem itm)
 {
     return _monitorMsmqQueues.Single(i => i.Queue.Type == itm.Queue.Type && i.Queue.Name == itm.Queue.Name);
 }
Example #26
0
    public void PurgeMessage(QueueItem itm) {

      InvokeWhileMonitoringPaused(() => {
        _mgr.PurgeMessage(itm);
      });

    }
        public void MoveErrorMessageToOriginQueue(QueueItem itm)
        {
            if (string.IsNullOrEmpty(itm.Id))
                throw new ArgumentException("MessageId can not be null or empty");

            if (itm.Queue.Type != QueueType.Error)
                throw new ArgumentException("Queue is not of type Error, " + itm.Queue.Type);

            var mgr = new ErrorManager();

            // TODO:
            // Check if Clustered Queue, due if Clustered && NonTransactional, then Error

            //var deserializer = new XmlMessageSerializer();

            XmlMessageSerializer _serializer = new XmlMessageSerializer();

            using (var stream = new MemoryStream(UTF8Encoding.Default.GetBytes(itm.Content ?? "")))
            {
                var rcx = ReceiveContext.FromBodyStream(stream);
                _serializer.Deserialize(rcx);

                //var query = rcx.DestinationAddress.Query;

                //var errorQueue = rcx.DestinationAddress.OriginalString.Replace(query, "") + "_error";

                //mgr.InputQueue = new EndpointAddress(errorQueue);

                mgr.ReturnMessageToSourceQueue(itm.Id, rcx);
            }
        }
Example #28
0
 public async Task MoveErrorMessageToOriginQueue(QueueItem itm) {
   InvokeWhileMonitoringPaused(() => {
     _mgr.MoveErrorMessageToOriginQueue(itm);
   });
 }
        private QueueItem CreateQueueItem(Queue queue, Message msg)
        {
            var itm = new QueueItem(queue);
            itm.DisplayName = msg.Label;
            itm.Id = msg.Id;
            itm.ArrivedTime = msg.ArrivedTime;
            //itm.Content = ReadMessageStream(msg.BodyStream);

            itm.Headers = new Dictionary<string, string>();
            if (msg.Extension.Length > 0)
            {
                var stream = new MemoryStream(msg.Extension);
                var transportMessageHeaders = TransportMessageHeaders.Create(stream.ToArray());
                //var o = headerSerializer.Deserialize(stream);

                var contentType = transportMessageHeaders["Content-Type"];
                var originalMessageId = transportMessageHeaders["Original-Message-Id"];

                if (contentType != null)
                    itm.Headers.Add("Content-Type", contentType);

                if (originalMessageId != null)
                    itm.Headers.Add("Original-Message-Id", originalMessageId);
            }


            return itm;
        }
        private void SetSelectedItem(QueueItem itm)
        {
            if( itm != null && itm.Content != null ) {

            if( _isMinimized )
              return;

            if( _dlgShown && !_dlg.IsVisible ) {
              _dlg = new ContentWindow();
              _dlg.Topmost = Topmost;

              _uiState.RestoreWindowState(_dlg);

              _dlgShown = false;
              UpdateContentWindow();
            }

            _dlg.SetContent(_mgr.LoadMessageContent(itm), itm.Error);

            //_dlg.Left = ( this.Left + this.Width ) - _dlg.Width;
            //_dlg.Top = this.Top - _dlg.Height;
            _dlg.SetTitle(itm.DisplayName);

            if( !_dlgShown ) {
              _dlg.Show();

              _dlgShown = true;
            } else {
              if( !Topmost ) {
            _dlg.Activate(); // Make sure its visible
            this.Activate();
              }
            }

            UpdateContextMenu(itm);
              } else {

            UpdateContextMenu(null);

            if( _dlg != null && _dlg.IsVisible )
              _dlg.Hide();

              }
        }
        /// <summary>
        ///     May throw a timeout exception if a message with the given id cannot be found.
        /// </summary>
        /// <param name="seqNumber"></param>
        public void ReturnMessageToSourceQueue(QueueClient queue, QueueClient deadLetterQueue, ServiceBusMQ.Model.QueueItem itm)
        {
            try {
                var message = deadLetterQueue.Receive((long)itm.MessageQueueItemId);

                message.Abandon();
                //queue.Send(message.Clone());
            } catch (Exception ex) {
                TryFindMessage(itm);
            }
        }
        private void UpdateContextMenu(QueueItem itm)
        {
            var items = lbItems.ContextMenu.Items;

              // Copy to Clipboard
              _UpdateContextMenuItem((MenuItem)items[0], itm);

              // Remove message
              var mi = (MenuItem)items[2];
              _UpdateContextMenuItem((MenuItem)items[2], itm);
              mi.IsEnabled = itm != null && !itm.Deleted;

              // Return Error Message to Origin
              mi = (MenuItem)items[5];
              _UpdateContextMenuItem(mi, itm);

              mi.IsEnabled = ( itm != null && itm.QueueType == QueueType.Error );

            #if DEBUG
              if( items.Count == 8 )
            items.Add(new MenuItem());

              mi = (MenuItem)items[8];
              mi.Header = "Header";

              mi.Items.Clear();

              if( itm != null && itm.Headers != null )
            foreach( var head in itm.Headers )
              mi.Items.Add( new MenuItem() { Header = string.Concat(head.Key, '=', head.Value) } );
            #endif
        }
 public void PurgeMessage(QueueItem itm)
 {
     _mgr.PurgeMessage(itm);
 }
        private void _UpdateContextMenuItem(MenuItem mi, QueueItem itm)
        {
            mi.IsEnabled = itm != null;

              if( itm != null )
            mi.Tag = itm;
        }
        private void _BindContextMenuItem(MenuItem mi, QueueItem itm, Func<QueueItem, bool> eval = null)
        {
            mi.IsEnabled = itm != null && ( eval == null || eval(itm) );

              if( itm != null )
            mi.Tag = itm;
        }
 public abstract string LoadMessageContent(QueueItem itm);
        private void SetSelectedItem(QueueItem itm)
        {
            if( itm != null ) {

            if( _isMinimized )
              return;

            if( _dlg == null || ( _dlgShown && !_dlg.IsVisible ) ) {
              _dlg = CreateContentWindow();

              _dlgShown = false;
              UpdateContentWindow();
            }

            var content = GetQueueItemContent(itm);

            //_mgr.MessageContentFormat
            _dlg.SetContent(content, itm.Queue.ContentFormat, itm.Error);
            _dlg.SetTitle(itm.DisplayName);

            if( !_dlgShown ) {
              _dlg.Show();

              _dlgShown = true;

              this.Focus();
            } else {
              if( !Topmost ) {
            _dlg.Activate(); // Make sure its visible
            this.Activate();
              }
            }

            UpdateContextMenu(itm);
              } else {

            UpdateContextMenu(null);

            if( _dlg != null && _dlg.IsVisible )
              _dlg.Hide();

              }
        }
        /// <summary>
        ///     May throw a timeout exception if a message with the given id cannot be found.
        /// </summary>
        /// <param name="seqNumber"></param>
        public void ReturnMessageToSourceQueue(QueueClient queue, QueueClient deadLetterQueue, ServiceBusMQ.Model.QueueItem itm)
        {
            //var rec = MessagingFactory.Create()
            //rec.

            BrokeredMessage message;

            try {
                message = deadLetterQueue.Receive((long)itm.MessageQueueItemId);
            } catch (Exception e) {
                message = queue.Receive((long)itm.MessageQueueItemId);
            }

            //message.Abandon();
            queue.Send(message.Clone());


            //} catch( Exception ex ) {
            //  TryFindMessage(itm);
            //}
        }