Example #1
0
        /// <summary>
        /// Creates and initializes new persistent delivery handler for the queue
        /// </summary>
        /// <param name="builder">Delivery handler builder</param>
        /// <param name="factory">Creates new persistent delivery handler instance</param>
        /// <returns></returns>
        public static async Task <IMessageDeliveryHandler> CreatePersistentDeliveryHandler(this DeliveryHandlerBuilder builder,
                                                                                           Func <DatabaseOptions, IPersistentDeliveryHandler> factory)
        {
            DatabaseOptions            databaseOptions = ConfigurationFactory.Builder.CreateOptions(builder.Queue);
            IPersistentDeliveryHandler handler         = factory(databaseOptions);
            await handler.Initialize();

            builder.OnAfterCompleted(AfterDeliveryHandlerCreated);
            return(handler);
        }
Example #2
0
 /// <summary>
 /// Creates and returns persistent queue
 /// </summary>
 internal static async Task <HorseQueue> CreateQueue(HorseMq mq,
                                                     string queueName,
                                                     QueueOptions options,
                                                     Func <DatabaseOptions, IPersistentDeliveryHandler> factory)
 {
     return(await mq.CreateQueue(queueName, options, async builder =>
     {
         DatabaseOptions databaseOptions = ConfigurationFactory.Builder.CreateOptions(builder.Queue);
         IPersistentDeliveryHandler handler = factory(databaseOptions);
         await handler.Initialize();
         return handler;
     }));
 }
Example #3
0
 /// <summary>
 /// Creates and returns persistent queue
 /// </summary>
 internal static async Task <HorseQueue> CreateQueue(HorseMq mq,
                                                     string queueName,
                                                     DeleteWhen deleteWhen,
                                                     ProducerAckDecision producerAckDecision,
                                                     QueueOptions options)
 {
     return(await mq.CreateQueue(queueName, options, async builder =>
     {
         DatabaseOptions databaseOptions = ConfigurationFactory.Builder.CreateOptions(builder.Queue);
         PersistentDeliveryHandler handler = new PersistentDeliveryHandler(builder.Queue, databaseOptions, deleteWhen, producerAckDecision);
         await handler.Initialize();
         return handler;
     }));
 }
Example #4
0
        /// <summary>
        /// Creates and initializes new persistent delivery handler for the queue
        /// </summary>
        /// <param name="builder">Delivery handler builder</param>
        /// <param name="deleteWhen">Decision when messages are deleted from disk</param>
        /// <param name="producerAckDecision">Decision when producer receives acknowledge</param>
        /// <param name="useRedelivery">True if want to keep redelivery data and send to consumers with message headers</param>
        /// <param name="key">Definition key for delivery handler. You can manage with that key, how the queue will be reloaded.</param>
        /// <param name="ackTimeoutPutback">Putback decision when ack message isn't received</param>
        /// <param name="nackPutback">Putback decision when negative ack is received</param>
        /// <returns></returns>
        public static async Task <IMessageDeliveryHandler> CreatePersistentDeliveryHandler(this DeliveryHandlerBuilder builder,
                                                                                           DeleteWhen deleteWhen,
                                                                                           ProducerAckDecision producerAckDecision,
                                                                                           bool useRedelivery = false,
                                                                                           PutBackDecision ackTimeoutPutback = PutBackDecision.End,
                                                                                           PutBackDecision nackPutback       = PutBackDecision.End,
                                                                                           string key = "default")
        {
            DatabaseOptions           databaseOptions = ConfigurationFactory.Builder.CreateOptions(builder.Queue);
            PersistentDeliveryHandler handler         = new PersistentDeliveryHandler(builder.Queue, databaseOptions, deleteWhen, producerAckDecision, useRedelivery, key);

            handler.AckTimeoutPutBack  = ackTimeoutPutback;
            handler.NegativeAckPutBack = nackPutback;
            await handler.Initialize();

            builder.OnAfterCompleted(AfterDeliveryHandlerCreated);
            return(handler);
        }
Example #5
0
 /// <summary>
 /// Creates new persistent delivery handler
 /// </summary>
 public PersistentDeliveryHandler(HorseQueue queue,
                                  DatabaseOptions options,
                                  DeleteWhen deleteWhen,
                                  ProducerAckDecision producerAckDecision,
                                  bool useRedelivery = false,
                                  string key         = "default")
 {
     Queue               = queue;
     DeleteWhen          = deleteWhen;
     ProducerAckDecision = producerAckDecision;
     Database            = new Database(options);
     UseRedelivery       = useRedelivery;
     Key = key;
     if (string.IsNullOrEmpty(Key))
     {
         Key = "default";
     }
 }
Example #6
0
 /// <summary>
 /// Creates new queue database
 /// </summary>
 public Database(DatabaseOptions options)
 {
     Options        = options;
     File           = new DatabaseFile(this);
     _shrinkManager = new ShrinkManager(this);
 }