/// <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(OpenedQueue queue, string messageId) { using (var timeoutQueue = queue.OpenSubQueue(SubQueue.Timeout, QueueAccessMode.Receive)) { var message = timeoutQueue.ReceiveById(messageId); message.AppSpecific = 0; // reset timeout flag queue.Send(message); } }
private void ProcessMessage( Message message, OpenedQueue messageQueue, TransactionScope tx, Func <CurrentMessageInformation, bool> messageRecieved, Action <CurrentMessageInformation> beforeMessageTransactionCommit, Action <CurrentMessageInformation> beforeMessageTransactionRollback, Action <CurrentMessageInformation, Exception> messageCompleted) { Exception ex = null; currentMessageInformation = CreateMessageInformation(messageQueue, message, null, null); try { // deserialization errors do not count for module events var messages = DeserializeMessages(messageQueue, message, MessageSerializationException); try { foreach (object msg in messages) { currentMessageInformation = CreateMessageInformation(messageQueue, message, messages, msg); if (TransportUtil.ProcessSingleMessage(currentMessageInformation, messageRecieved) == false) { Discard(currentMessageInformation.Message); } } } catch (Exception e) { ex = e; logger.Error("Failed to process message", e); } } catch (Exception e) { ex = e; logger.Error("Failed to deserialize message", e); } finally { Action sendMessageBackToQueue = null; if (message != null && (messageQueue.IsTransactional == false || consumeInTransaction == false)) { sendMessageBackToQueue = () => messageQueue.Send(message); } var messageHandlingCompletion = new MessageHandlingCompletion(tx, sendMessageBackToQueue, ex, messageCompleted, beforeMessageTransactionCommit, beforeMessageTransactionRollback, logger, MessageProcessingFailure, currentMessageInformation); messageHandlingCompletion.HandleMessageCompletion(); currentMessageInformation = null; } }
public void SendToErrorQueue(OpenedQueue queue, Message message) { queue.Send(message); }