示例#1
0
 /// <summary>
 /// Initialize a new instance of the <see cref="MsmqJobQueueFactory"/>
 /// </summary>
 /// <param name="payloadFormatter">Formats object payloads added to queue</param>
 /// <param name="requestSerializer">Deserializes payload coming from the queue</param>
 /// <param name="accessControlList">Specifies users and their access to the queue</param>
 public MsmqJobQueueFactory(
     IPayloadFormatter payloadFormatter,
     IRequestSerializer requestSerializer,
     System.Messaging.AccessControlList accessControlList = null)
 {
     _queueFactory      = new MsmqMessageQueueFactory(accessControlList);
     _messageFactory    = new MsmqMessageFactory();
     _payloadFormatter  = payloadFormatter;
     _requestSerializer = requestSerializer;
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobQueue"/> class
        /// </summary>
        /// <param name="queueFactory">Factory for creating the queue</param>
        /// <param name="messageFactory">Factory for creating new messages</param>
        /// <param name="formatter">Formatter for formatting payloads</param>
        /// <param name="serializer">Serializer for serializing requests</param>
        /// <param name="handlerConfiguration">Configuration creating handlers (used to copy into a <see cref="QueueCreationOptions"/> object</param>
        public JobQueue(
            IMessageQueueFactory queueFactory,
            IMessageFactory messageFactory,
            IPayloadFormatter formatter,
            IRequestSerializer serializer,
            HandlerConfiguration handlerConfiguration)
        {
            if (handlerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(handlerConfiguration));
            }

            _messageQueueFactory = queueFactory ?? throw new ArgumentNullException(nameof(queueFactory));
            _messageFactory      = messageFactory ?? throw new ArgumentNullException(nameof(messageFactory));
            _formatter           = formatter ?? throw new ArgumentNullException(nameof(formatter));
            _serializer          = serializer ?? throw new ArgumentNullException(nameof(serializer));

            _queue = _messageQueueFactory.Create(handlerConfiguration.ToQueueCreationOptions());
            _queue.ReceivedMessage += OnReceivedJob;
        }