/// <summary>
 /// Moves the message from the timeout queue to the main queue.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="messageId">The message id.</param>
 public void MoveTimeoutToMainQueue(MessageQueue queue, string messageId)
 {
     var fullSubQueueName = queue.Path + ";timeout";
     using (var timeoutQueue = new MessageQueue(fullSubQueueName, QueueAccessMode.Receive))
     {
         var message = timeoutQueue.ReceiveById(messageId, queue.GetTransactionType());
         message.AppSpecific = 0;//reset timeout flag
         queue.Send(message, queue.GetTransactionType());
     }
 }
 /// <summary>
 /// Moves the message from the timeout queue to the main queue.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="messageId">The message id.</param>
 public void MoveTimeoutToMainQueue(MessageQueue queue, string messageId)
 {
     using (var destinationQueue = new MessageQueue(GetTimeoutQueuePath(), QueueAccessMode.Receive))
     {
         var message = destinationQueue.ReceiveById(messageId, queue.GetTransactionType());
         message.AppSpecific = 0;//reset timeout flag
         queue.Send(message, destinationQueue.GetTransactionType());
     }
 }
        private void MoveToErrorQueue(MessageQueue queue, Message message, string exceptionText)
        {
            queueStrategy.MoveToErrorsQueue(queue, message);
            var label = "Error description for " + message.Label;
            if (label.Length > 249)
                label = label.Substring(0, 246) + "...";
            queue.Send(new Message
            {
                AppSpecific = (int)MessageType.ErrorDescriptionMessageMarker,
                Label = label,
                Body = exceptionText,
                CorrelationId = message.Id,
            }, queue.GetTransactionType());

            logger.WarnFormat("Moving message {0} to errors subqueue because: {1}", message.Id,
                              exceptionText);
        }
 /// <summary>
 /// Moves the <paramref name="message"/> to errors queue.
 /// </summary>
 /// <param name="queue">The queue.</param>
 /// <param name="message">The message.</param>
 public void MoveToErrorsQueue(MessageQueue queue, Message message)
 {
     using (var destinationQueue = new MessageQueue(GetErrorsQueuePath(),QueueAccessMode.Send))
     {
         destinationQueue.Send(queue.ReceiveByLookupId(message.LookupId),
                               queue.GetTransactionType());
     }
 }
        private void SendMessageToQueue(Message message, Uri uri)
        {
            if (haveStarted == false)
                throw new TransportException("Cannot send message before transport is started");

            string sendQueueDescription = MsmqUtil.GetQueuePath(uri);
            try
            {
                using (var sendQueue = new MessageQueue(
                    sendQueueDescription,
                    QueueAccessMode.Send))
                {
                    MessageQueueTransactionType transactionType = sendQueue.GetTransactionType();
                    sendQueue.Send(message, transactionType);
                    logger.DebugFormat("Send message {0} to {1}", message.Label, uri);
                }
            }
            catch (Exception e)
            {
                throw new TransactionException("Failed to send message to " + uri, e);
            }
        }