Exemplo n.º 1
0
        /// <summary>
        /// Publishes the specified message to the specified queue.
        /// </summary>
        /// <param name="message">Message to queue.</param>
        /// <param name="queue">Queue to place message in.</param>
        /// <param name="priority">Priority of message.</param>
        public static async Task <bool> Publish(object obj, RabbitMqQueue queue, bool confirm = true, RabbitMqPriority priority = RabbitMqPriority.Low)
        {
            byte[] bytes = await Serialisation.Serialise(obj);

            return(Publish(bytes, queue, !confirm, priority));
        }
        /// <summary>
        /// Enqueues the Email that we are going to relay in RabbitMQ.
        /// </summary>
        /// <param name="messageID">ID of the Message being Queued.</param>
        /// <param name="ipGroupID">ID of the Virtual MTA Group to send the Message through.</param>
        /// <param name="internalSendID">ID of the Send the Message is apart of.</param>
        /// <param name="mailFrom">The envelope mailfrom, should be return-path in most instances.</param>
        /// <param name="rcptTo">The envelope rcpt to.</param>
        /// <param name="message">The Email.</param>
        /// <param name="priority">Priority of message.</param>
        /// <returns>True if the Email has been enqueued in RabbitMQ.</returns>
        public static async Task <bool> Enqueue(Guid messageID, int ipGroupID, int internalSendID, string mailFrom, string[] rcptTo, string message, RabbitMqPriority priority)
        {
            // Create the thing we are going to queue in RabbitMQ.
            var recordToSave = new MtaMessage
            {
                ID                = messageID,
                InternalSendID    = internalSendID,
                MailFrom          = mailFrom,
                Message           = message,
                RcptTo            = rcptTo,
                VirtualMTAGroupID = ipGroupID,
                RabbitMqPriority  = priority
            };

            return(await RabbitMqManager.Publish(MtaQueuedMessage.CreateNew(recordToSave), RabbitMqManager.RabbitMqQueue.InboundStaging, true, priority));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Publishes the specified message to the specified queue.
        /// </summary>
        /// <param name="message">Message to queue.</param>
        /// <param name="queue">Queue to place message in.</param>
        /// <param name="priority">Priority of message.</param>
        public static bool Publish(byte[] message, RabbitMqQueue queue, bool noConfirm, RabbitMqPriority priority)
        {
            var pChannel = GetPublishChannel(queue, noConfirm);

            lock (pChannel.Lock)
            {
                var channel  = pChannel.Channel;
                var msgProps = channel.CreateBasicProperties();
                msgProps.Persistent = true;
                msgProps.Priority   = (byte)priority;
                channel.BasicPublish(string.Empty, GetQueueNameFromEnum(queue), true, msgProps, message);

                return(noConfirm ? true
                                 : channel.WaitForConfirms());
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Enqueues the Inbound Message for Relaying.
 /// </summary>
 /// <param name="messageID">ID of the Message being Queued.</param>
 /// <param name="ipGroupID">ID of the Virtual MTA Group to send the Message through.</param>
 /// <param name="internalSendID">ID of the Send the Message is apart of.</param>
 /// <param name="mailFrom">The envelope mailfrom, should be return-path in most instances.</param>
 /// <param name="rcptTo">The envelope rcpt to.</param>
 /// <param name="message">The Email.</param>
 /// <param name="priority">Priority of message.</param>
 /// <returns>True if the Message has been queued, false if not.</returns>
 public async Task <bool> Enqueue(Guid messageID, int ipGroupID, int internalSendID, string mailFrom, string[] rcptTo, string message, RabbitMqPriority priority)
 {
     return(await RabbitMq.RabbitMqInboundQueueManager.Enqueue(messageID, ipGroupID, internalSendID, mailFrom, rcptTo, message, priority));
 }