示例#1
0
 internal static QueueOptions ToOptions(this QueueOptionsConfiguration configuration)
 {
     return(new QueueOptions
     {
         Acknowledge = configuration.Acknowledge.ToAckDecision(),
         Status = configuration.Status.ToQueueStatus(),
         AcknowledgeTimeout = TimeSpan.FromMilliseconds(configuration.AcknowledgeTimeout),
         MessageTimeout = TimeSpan.FromMilliseconds(configuration.AcknowledgeTimeout),
         MessageLimit = configuration.MessageLimit,
         HideClientNames = configuration.HideClientNames,
         MessageSizeLimit = configuration.MessageSizeLimit,
         UseMessageId = configuration.UseMessageId,
         ClientLimit = configuration.ClientLimit,
         DelayBetweenMessages = configuration.DelayBetweenMessages,
         PutBackDelay = configuration.PutBackDelay
     });
 }
        /// <summary>
        /// Adds new queue into configurations
        /// </summary>
        public bool Add(HorseQueue queue, string filename)
        {
            QueueOptionsConfiguration queueOptions = queue.Options.ToConfiguration();

            QueueConfiguration queueConfiguration = new QueueConfiguration();

            queueConfiguration.Configuration = queueOptions;
            queueConfiguration.Name          = queue.Name;
            queueConfiguration.File          = filename;
            queueConfiguration.Queue         = queue;

            if (queue.DeliveryHandler is IPersistentDeliveryHandler deliveryHandler)
            {
                queueConfiguration.DeliveryHandler = deliveryHandler.Key;
                queueConfiguration.DeleteWhen      = Convert.ToInt32(deliveryHandler.DeleteWhen);
                queueConfiguration.ProducerAck     = Convert.ToInt32(deliveryHandler.ProducerAckDecision);
            }

            lock (_optionsLock)
                Config.Queues.Add(queueConfiguration);

            return(true);
        }