/// <summary> /// Enqueue the message for relaying. /// </summary> /// <param name="msg">Message to enqueue.</param> public static async Task <bool> Enqueue(MtaQueuedMessage msg) { RabbitMqManager.RabbitMqQueue queue = RabbitMqManager.RabbitMqQueue.OutboundWaiting; int secondsUntilNextAttempt = (int)Math.Ceiling((msg.AttemptSendAfterUtc - DateTime.UtcNow).TotalSeconds); if (secondsUntilNextAttempt > 0) { if (secondsUntilNextAttempt < 10) { queue = RabbitMqManager.RabbitMqQueue.OutboundWait1; } else if (secondsUntilNextAttempt < 60) { queue = RabbitMqManager.RabbitMqQueue.OutboundWait10; } else if (secondsUntilNextAttempt < 300) { queue = RabbitMqManager.RabbitMqQueue.OutboundWait60; } else { queue = RabbitMqManager.RabbitMqQueue.OutboundWait300; } } var published = await RabbitMqManager.Publish(msg, queue, priority : msg.RabbitMqPriority); if (published) { msg.IsHandled = true; } return(published); }
/// <summary> /// Enqueue the message for relaying. /// </summary> /// <param name="msg">Message to enqueue.</param> public static bool Enqueue(MtaQueuedMessage msg) { RabbitMqManager.RabbitMqQueue queue = RabbitMqManager.RabbitMqQueue.OutboundWaiting; int secondsUntilNextAttempt = (int)Math.Ceiling((msg.AttemptSendAfterUtc - DateTime.UtcNow).TotalSeconds); if (secondsUntilNextAttempt > 0) { if (secondsUntilNextAttempt < 10) { queue = RabbitMqManager.RabbitMqQueue.OutboundWait1; } else if (secondsUntilNextAttempt < 60) { queue = RabbitMqManager.RabbitMqQueue.OutboundWait10; } else if (secondsUntilNextAttempt < 300) { queue = RabbitMqManager.RabbitMqQueue.OutboundWait60; } else { queue = RabbitMqManager.RabbitMqQueue.OutboundWait300; } } if (!RabbitMqManager.Publish(msg, queue)) { return(false); } msg.IsHandled = true; return(true); }