Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultExtendedQueueFactory" /> class.
        /// </summary>
        /// <param name="messageProvider">An object that will generate a proper instance of <see cref="IQueueMessage" />.</param>
        /// <param name="maximumMessageSizeProvider">An object that will report the maximum size of a message.</param>
        /// <param name="maximumMessagePerRequestProvider">An object that will report the maximum amount of messages that can be retrieved per request.</param>
        /// <param name="overflownMessageHandler">An object that handles messages that are overflown and should be recorded in a temporary storage.</param>
        /// <param name="logService">The logging service to use.</param>
        public DefaultExtendedQueueFactory(
            [NotNull] IQueueMessageProvider messageProvider,
            [NotNull] IMaximumMessageSizeProvider maximumMessageSizeProvider,
            [NotNull] IMaximumMessagesPerRequestProvider maximumMessagePerRequestProvider,
            [NotNull] IOverflownMessageHandler overflownMessageHandler,
            [NotNull] ILogService logService)
        {
            Guard.NotNull(messageProvider, "messageProvider");
            Guard.NotNull(maximumMessageSizeProvider, "maximumMessageSizeProvider");
            Guard.NotNull(maximumMessagePerRequestProvider, "maximumMessagePerRequestProvider");
            Guard.NotNull(overflownMessageHandler, "overflownMessageHandler");
            Guard.NotNull(logService, "logService");


            this.MessageProvider            = messageProvider;
            this.MaximumMessageSizeProvider = maximumMessageSizeProvider;
            this.MaximumMessagesProvider    = maximumMessagePerRequestProvider;
            this.OverflownMessageHandler    = overflownMessageHandler;
            this.LogService = logService;

            this.Decorators = new List <Func <ExtendedQueueBase, DecoratorBase> >
            {
                q => new CompressionDecorator(q),
                q => new JsonSerialiserDecorator(q),
                q => new OverflowHandlingDecorator(q, this.OverflownMessageHandler),
                q => new LoggingDecorator(q, this.LogService)
            };
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OverflowHandlingDecorator"/> class.
 /// </summary>
 /// <param name="decoratedQueue">The decorated queue.</param>
 /// <param name="overflownMessageHandler">The overflown message handler.</param>
 public OverflowHandlingDecorator(ExtendedQueueBase decoratedQueue, IOverflownMessageHandler overflownMessageHandler) : base(decoratedQueue)
 {
     this.OverflownMessageHandler = overflownMessageHandler;
 }