public QueueListener(IStorageQueue queue,
            IStorageQueue poisonQueue,
            ITriggerExecutor<IStorageQueueMessage> triggerExecutor,
            IDelayStrategy delayStrategy,
            IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
            TraceWriter trace,
            SharedQueueWatcher sharedWatcher,
            IQueueConfiguration queueConfiguration)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            if (queueConfiguration == null)
            {
                throw new ArgumentNullException("queueConfiguration");
            }

            if (queueConfiguration.BatchSize <= 0)
            {
                throw new ArgumentException("BatchSize must be greater than zero.");
            }

            if (queueConfiguration.MaxDequeueCount <= 0)
            {
                throw new ArgumentException("MaxDequeueCount must be greater than zero.");
            }

            _timer = new TaskSeriesTimer(this, backgroundExceptionDispatcher, Task.Delay(0));
            _queue = queue;
            _poisonQueue = poisonQueue;
            _triggerExecutor = triggerExecutor;
            _delayStrategy = delayStrategy;
            _backgroundExceptionDispatcher = backgroundExceptionDispatcher;
            _trace = trace;
            _queueConfiguration = queueConfiguration;

            if (sharedWatcher != null)
            {
                // Call Notify whenever a function adds a message to this queue.
                sharedWatcher.Register(queue.Name, this);
                _sharedWatcher = sharedWatcher;
            }

            EventHandler poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler)null;
            _queueProcessor = CreateQueueProcessor(
                _queue.SdkObject, _poisonQueue != null ? _poisonQueue.SdkObject : null,
                _trace, _queueConfiguration, poisonMessageEventHandler);
        }
Пример #2
0
        //private int cnt = 0;
        //private static int counter = 0;
        /// <summary>
        /// Constructs a new <c>FileQueue</c> with the specified properties.
        /// </summary>
        /// <param name="location">The absolute path to the directory for the queue.</param>
        /// <param name="checkInterval">The interval, in minutes, at which to process
        ///			entries in the queue.</param>
        /// <param name="processMethod">The method to call to process entries in
        ///			the queue.</param>
        public FileQueue(
            String location,
            int checkInterval,
            QueueProcessor processMethod)
        {
            this.queueInfo = new QueueInfo();
            this.queueInfo.queueLocation = location;
            this.queueInfo.checkInterval = checkInterval;
            this.queueInfo.processingMethod = processMethod;

            //  make sure the path to the queue directory ends with \
            if (!this.queueInfo.queueLocation.EndsWith("\\")) {
                this.queueInfo.queueLocation += "\\";
            }

            this.SetTimer();
            //cnt = ++counter;
        }
Пример #3
0
        public QueueListener(IStorageQueue queue,
                             IStorageQueue poisonQueue,
                             ITriggerExecutor <IStorageQueueMessage> triggerExecutor,
                             IWebJobsExceptionHandler exceptionHandler,
                             TraceWriter trace,
                             ILoggerFactory loggerFactory,
                             SharedQueueWatcher sharedWatcher,
                             IQueueConfiguration queueConfiguration,
                             QueueProcessor queueProcessor = null,
                             TimeSpan?maxPollingInterval   = null)
        {
            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            if (queueConfiguration == null)
            {
                throw new ArgumentNullException("queueConfiguration");
            }

            if (queueConfiguration.BatchSize <= 0)
            {
                throw new ArgumentException("BatchSize must be greater than zero.");
            }

            if (queueConfiguration.MaxDequeueCount <= 0)
            {
                throw new ArgumentException("MaxDequeueCount must be greater than zero.");
            }

            _timer              = new TaskSeriesTimer(this, exceptionHandler, Task.Delay(0));
            _queue              = queue;
            _poisonQueue        = poisonQueue;
            _triggerExecutor    = triggerExecutor;
            _exceptionHandler   = exceptionHandler;
            _queueConfiguration = queueConfiguration;

            // if the function runs longer than this, the invisibility will be updated
            // on a timer periodically for the duration of the function execution
            _visibilityTimeout = TimeSpan.FromMinutes(10);

            if (sharedWatcher != null)
            {
                // Call Notify whenever a function adds a message to this queue.
                sharedWatcher.Register(queue.Name, this);
                _sharedWatcher = sharedWatcher;
            }

            EventHandler <PoisonMessageEventArgs> poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler <PoisonMessageEventArgs>)null;

            _queueProcessor = queueProcessor ?? CreateQueueProcessor(
                _queue.SdkObject, _poisonQueue != null ? _poisonQueue.SdkObject : null,
                trace, loggerFactory, _queueConfiguration, poisonMessageEventHandler);

            TimeSpan maximumInterval = _queueProcessor.MaxPollingInterval;

            if (maxPollingInterval.HasValue && maximumInterval > maxPollingInterval.Value)
            {
                // enforce the maximum polling interval if specified
                maximumInterval = maxPollingInterval.Value;
            }

            _delayStrategy = new RandomizedExponentialBackoffStrategy(QueuePollingIntervals.Minimum, maximumInterval);
        }
        public void CreateQueueProcessor_CreatesProcessorCorrectly()
        {
            CloudQueue      poisonQueue = null;
            TestTraceWriter log         = new TestTraceWriter(TraceLevel.Verbose);
            bool            poisonMessageHandlerInvoked             = false;
            EventHandler    poisonMessageEventHandler               = (sender, e) => { poisonMessageHandlerInvoked = true; };
            Mock <IQueueProcessorFactory> mockQueueProcessorFactory = new Mock <IQueueProcessorFactory>(MockBehavior.Strict);
            JobHostQueuesConfiguration    queueConfig               = new JobHostQueuesConfiguration
            {
                MaxDequeueCount       = 7,
                QueueProcessorFactory = mockQueueProcessorFactory.Object
            };
            QueueProcessor expectedQueueProcessor  = null;
            bool           processorFactoryInvoked = false;

            // create for a host queue - don't expect custom factory to be invoked
            CloudQueue     queue          = new CloudQueue(new Uri(string.Format("https://test.queue.core.windows.net/{0}", HostQueueNames.GetHostQueueName("12345"))));
            QueueProcessor queueProcessor = QueueListener.CreateQueueProcessor(queue, poisonQueue, log, queueConfig, poisonMessageEventHandler);

            Assert.False(processorFactoryInvoked);
            Assert.NotSame(expectedQueueProcessor, queueProcessor);
            queueProcessor.OnMessageAddedToPoisonQueue(new EventArgs());
            Assert.True(poisonMessageHandlerInvoked);

            QueueProcessorFactoryContext processorFactoryContext = null;

            mockQueueProcessorFactory.Setup(p => p.Create(It.IsAny <QueueProcessorFactoryContext>()))
            .Callback <QueueProcessorFactoryContext>((mockProcessorContext) =>
            {
                processorFactoryInvoked = true;

                Assert.Same(queue, mockProcessorContext.Queue);
                Assert.Same(poisonQueue, mockProcessorContext.PoisonQueue);
                Assert.Equal(queueConfig.MaxDequeueCount, mockProcessorContext.MaxDequeueCount);
                Assert.Same(log, mockProcessorContext.Trace);

                processorFactoryContext = mockProcessorContext;
            })
            .Returns(() =>
            {
                expectedQueueProcessor = new QueueProcessor(processorFactoryContext);
                return(expectedQueueProcessor);
            });

            // when storage host is "localhost" we invoke the processor factory even for
            // host queues (this enables local test mocking)
            processorFactoryInvoked = false;
            queue          = new CloudQueue(new Uri(string.Format("https://localhost/{0}", HostQueueNames.GetHostQueueName("12345"))));
            queueProcessor = QueueListener.CreateQueueProcessor(queue, poisonQueue, log, queueConfig, poisonMessageEventHandler);
            Assert.True(processorFactoryInvoked);
            Assert.Same(expectedQueueProcessor, queueProcessor);

            // create for application queue - expect processor factory to be invoked
            poisonMessageHandlerInvoked = false;
            processorFactoryInvoked     = false;
            queue          = new CloudQueue(new Uri("https://test.queue.core.windows.net/testqueue"));
            queueProcessor = QueueListener.CreateQueueProcessor(queue, poisonQueue, log, queueConfig, poisonMessageEventHandler);
            Assert.True(processorFactoryInvoked);
            Assert.Same(expectedQueueProcessor, queueProcessor);
            queueProcessor.OnMessageAddedToPoisonQueue(new EventArgs());
            Assert.True(poisonMessageHandlerInvoked);

            // if poison message watcher not specified, event not subscribed to
            poisonMessageHandlerInvoked = false;
            processorFactoryInvoked     = false;
            queueProcessor = QueueListener.CreateQueueProcessor(queue, poisonQueue, log, queueConfig, null);
            Assert.True(processorFactoryInvoked);
            Assert.Same(expectedQueueProcessor, queueProcessor);
            queueProcessor.OnMessageAddedToPoisonQueue(new EventArgs());
            Assert.False(poisonMessageHandlerInvoked);
        }
Пример #5
0
        public static void Setup(GameObject go)
        {
            string body = "body";

            string[] eyelash = new string[] { "eyelash", "default" };
            string   head    = "head";
            string   eyeL    = "lefteye";
            string   eyeR    = "righteye";
            string   blinkL  = "blink_left";
            string   blinkR  = "blink_right";

            if (go)
            {
                Eyes eyes = go.GetComponent <Eyes>();
                if (eyes == null)
                {
                    eyes = go.AddComponent <Eyes>();
                }
                else
                {
                    DestroyImmediate(eyes);
                    eyes = go.AddComponent <Eyes>();
                }
                QueueProcessor qp = go.GetComponent <QueueProcessor>();
                if (qp == null)
                {
                    qp = go.AddComponent <QueueProcessor>();
                }

                // System Properties
                eyes.characterRoot  = go.transform;
                eyes.queueProcessor = qp;

                // Heads - Bone_Rotation
                eyes.BuildHeadTemplate(Eyes.HeadTemplates.Bone_Rotation_XY);
                eyes.heads[0].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, head);
                eyes.heads[0].expData.name = "head";
                eyes.heads[0].expData.components[0].name = "head";
                eyes.headTargetOffset.y = 0.052f;
                eyes.CaptureMin(ref eyes.heads);
                eyes.CaptureMax(ref eyes.heads);

                // Eyes - Bone_Rotation
                eyes.BuildEyeTemplate(Eyes.EyeTemplates.Bone_Rotation);
                eyes.eyes[0].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, eyeL);
                eyes.eyes[0].expData.name = "eyeL";
                eyes.eyes[0].expData.components[0].name     = "eyeL";
                eyes.eyes[1].expData.controllerVars[0].bone = Eyes.FindTransform(eyes.characterRoot, eyeR);
                eyes.eyes[1].expData.name = "eyeR";
                eyes.eyes[1].expData.components[0].name = "eyeR";
                eyes.CaptureMin(ref eyes.eyes);
                eyes.CaptureMax(ref eyes.eyes);

                // Blinklids - Bone_Rotation
                eyes.BuildEyelidTemplate(Eyes.EyelidTemplates.BlendShapes, Eyes.EyelidSelection.Upper); // includes left/right eyelid
                eyes.AddEyelidShapeExpression(ref eyes.blinklids);                                      // add eyelash left
                eyes.AddEyelidShapeExpression(ref eyes.blinklids);                                      // add eyelash right
                float blinkMax = 0.75f;
                // Left eyelid
                eyes.blinklids[0].expData.controllerVars[0].smr        = Eyes.FindTransform(eyes.characterRoot, body).GetComponent <SkinnedMeshRenderer>();
                eyes.blinklids[0].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[0].expData.controllerVars[0].smr, blinkL);
                eyes.blinklids[0].expData.controllerVars[0].maxShape   = blinkMax;
                eyes.blinklids[0].expData.name = "eyelidL";
                // Right eyelid
                eyes.blinklids[1].expData.controllerVars[0].smr        = eyes.blinklids[0].expData.controllerVars[0].smr;
                eyes.blinklids[1].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[1].expData.controllerVars[0].smr, blinkR);
                eyes.blinklids[1].expData.controllerVars[0].maxShape   = blinkMax;
                eyes.blinklids[1].expData.name = "eyelidR";
                // Left eyelash
                eyes.blinklids[2].expData.controllerVars[0].smr        = Eyes.FindTransform(eyes.characterRoot, eyelash).GetComponent <SkinnedMeshRenderer>();
                eyes.blinklids[2].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[2].expData.controllerVars[0].smr, blinkL);
                eyes.blinklids[2].expData.controllerVars[0].maxShape   = blinkMax;
                eyes.blinklids[2].expData.name = "eyelashL";
                // Right eyelash
                eyes.blinklids[3].expData.controllerVars[0].smr        = eyes.blinklids[2].expData.controllerVars[0].smr;
                eyes.blinklids[3].expData.controllerVars[0].blendIndex = Eyes.FindBlendIndex(eyes.blinklids[3].expData.controllerVars[0].smr, blinkR);
                eyes.blinklids[3].expData.controllerVars[0].maxShape   = blinkMax;
                eyes.blinklids[3].expData.name = "eyelashR";

                // Tracklids
                eyes.CopyBlinkToTrack();
                // Set track eye index
                eyes.tracklids[0].referenceIdx = 0; // left
                eyes.tracklids[1].referenceIdx = 1; // right
                eyes.tracklids[2].referenceIdx = 0; // left
                eyes.tracklids[3].referenceIdx = 1; // right

                // Initialize the Eyes module
                eyes.Initialize();
            }
        }
Пример #6
0
        public void ProcessElementTest()
        {
            var environmentFactory = EnvironmentFactoryFactory.Create();

            var queueSendAdapter = environmentFactory.QueueEnvironment.QueueSendAdapter;

            queueSendAdapter.Clear();

            var queueReceiverAdapter       = environmentFactory.QueueEnvironment.QueueReceiveAdapter;
            var directTelemetryDataService = Substitute.For <IDirectTelemetryDataService>();

            int COUNT = 50;

            var outputList = new List <TelemetryData>(COUNT);

            directTelemetryDataService.When(d => d.RecordTelemetryData(Arg.Any <TelemetryData>())).Do(call => outputList.Add((TelemetryData)call.Args()[0]));

            var queueProcessor = new QueueProcessor(queueReceiverAdapter, directTelemetryDataService);

            queueProcessor.Start();

            var inputList = new List <TelemetryData>(COUNT);

            for (var i = 0; i < COUNT; i++)
            {
                var inputTd = new TelemetryData((i % 5).ToString(), $"{{\"p\": {i}}}", DateTime.UtcNow);
                inputList.Add(inputTd);
                queueSendAdapter.Send(inputTd);
            }

            var ok = false;

            for (var r = 0; r < 30; r++)
            {
                if (outputList.Count == COUNT)
                {
                    bool isOk = true;
                    for (var i = 0; i < COUNT; i++)
                    {
                        var input  = inputList[i];
                        var output = outputList[i];

                        if (input.DeviceId != output.DeviceId.Trim() || input.Payload != output.Payload)
                        {
                            isOk = false;
                            break;
                        }
                    }
                    if (isOk)
                    {
                        ok = true;
                        break;
                    }
                }
                Thread.Sleep(100);
            }

            queueProcessor.Stop();

            Assert.IsTrue(ok);
        }
Пример #7
0
 public FileAppender()
 {
     _queue = new QueueProcessor <LogRecord>("FileAppender", RenderMessage);
 }
Пример #8
0
        static void Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", optional: false)
                                .Build();

            var courseService = new CourseService(
                privateKeyPath: configuration.GetSection("PrivateKeyPath").Value,
                emailToImpersonate: configuration.GetSection("AdminEmail").Value,
                scopes: new string[] { Scope.ClassroomCourses, Scope.ClassroomProfileEmails, Scope.ClassroomRosters }
                );

            Parser.Default.ParseArguments <AddStudentOptions,
                                           ExecuteCommandListOptions>
                (args)
            .WithParsed <AddStudentOptions>(opts =>
            {
                var addStudentToCourseCommand = new AddStudentToCourseCommand(
                    courseService: courseService,
                    courseId: opts.CourseId,
                    studentEmail: opts.Email
                    );

                addStudentToCourseCommand.Execute();
            })
            .WithParsed <ExecuteCommandListOptions>(opts =>
            {
                var logger = new Logger();
                var queue  = new QueueProcessor(logger);

                var textToCommandParser = new TextToCommandParser(courseService, logger);

                using (var reader = new StreamReader(opts.Path))
                {
                    string line;

                    while ((line = reader.ReadLine()) != null)
                    {
                        var command = textToCommandParser.Parse(line);
                        var node    = new Node(command);

                        if (node.Command.CommandType == CommandType.AddStudent)
                        {
                            var queueLastNode = queue.Queue.Last();
                            queueLastNode.Children.Add(node);
                        }
                        else
                        {
                            queue.Enqueue(node);
                        }
                    }
                }

                queue.ProcessQueue();

                if (queue.HasAnyNodeFailed && opts.Reprocess)
                {
                    queue.ReprocessFailedQueue();
                }
            })
            .WithNotParsed(errors =>
            {
                foreach (var error in errors)
                {
                    Console.WriteLine(error.ToString());
                }
            });
        }
Пример #9
0
 public void Dispose()
 {
     _queue?.Dispose();
     _queue = null;
 }
Пример #10
0
        public QueueListener(QueueClient queue,
                             QueueClient poisonQueue,
                             ITriggerExecutor <QueueMessage> triggerExecutor,
                             IWebJobsExceptionHandler exceptionHandler,
                             ILoggerFactory loggerFactory,
                             SharedQueueWatcher sharedWatcher,
                             QueuesOptions queueOptions,
                             IQueueProcessorFactory queueProcessorFactory,
                             FunctionDescriptor functionDescriptor,
                             string functionId           = null,
                             TimeSpan?maxPollingInterval = null)
        {
            if (queueOptions == null)
            {
                throw new ArgumentNullException(nameof(queueOptions));
            }

            if (queueProcessorFactory == null)
            {
                throw new ArgumentNullException(nameof(queueProcessorFactory));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            if (queueOptions.BatchSize <= 0)
            {
                throw new ArgumentException("BatchSize must be greater than zero.");
            }

            if (queueOptions.MaxDequeueCount <= 0)
            {
                throw new ArgumentException("MaxDequeueCount must be greater than zero.");
            }

            _timer              = new TaskSeriesTimer(this, exceptionHandler, Task.Delay(0));
            _queue              = queue;
            _poisonQueue        = poisonQueue;
            _triggerExecutor    = triggerExecutor;
            _exceptionHandler   = exceptionHandler;
            _queueOptions       = queueOptions;
            _logger             = loggerFactory.CreateLogger <QueueListener>();
            _functionDescriptor = functionDescriptor ?? throw new ArgumentNullException(nameof(functionDescriptor));
            _functionId         = functionId ?? _functionDescriptor.Id;

            // if the function runs longer than this, the invisibility will be updated
            // on a timer periodically for the duration of the function execution
            _visibilityTimeout = TimeSpan.FromMinutes(10);

            if (sharedWatcher != null)
            {
                // Call Notify whenever a function adds a message to this queue.
                sharedWatcher.Register(queue.Name, this);
                _sharedWatcher = sharedWatcher;
            }

            EventHandler <PoisonMessageEventArgs> poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler <PoisonMessageEventArgs>)null;

            _queueProcessor = CreateQueueProcessor(_queue, _poisonQueue, loggerFactory, queueProcessorFactory, _queueOptions, poisonMessageEventHandler);

            TimeSpan maximumInterval = _queueProcessor.MaxPollingInterval;

            if (maxPollingInterval.HasValue && maximumInterval > maxPollingInterval.Value)
            {
                // enforce the maximum polling interval if specified
                maximumInterval = maxPollingInterval.Value;
            }

            _delayStrategy = new RandomizedExponentialBackoffStrategy(SharedQueuePollingIntervals.Minimum, maximumInterval);

            _scaleMonitorDescriptor          = new ScaleMonitorDescriptor($"{_functionId}-QueueTrigger-{_queue.Name}".ToLower(CultureInfo.InvariantCulture));
            _shutdownCancellationTokenSource = new CancellationTokenSource();
        }
        public static void Setup(GameObject go, int lod)
        {
            string head   = "head";
            string eyeL   = "lefteye";
            string eyeR   = "righteye";
            string body   = "body";
            string blinkL = "^.*reyeclose.*$";
            string blinkR = "^.*leyeclose.*$";

            if (go)
            {
                Eyes eyes = go.GetComponent <Eyes>();
                if (eyes == null)
                {
                    eyes = go.AddComponent <Eyes>();
                }
                else
                {
                    DestroyImmediate(eyes);
                    eyes = go.AddComponent <Eyes>();
                }
                QueueProcessor qp = go.GetComponent <QueueProcessor>();
                if (qp == null)
                {
                    qp = go.AddComponent <QueueProcessor>();
                }

                // System Properties
                eyes.characterRoot  = go.transform;
                eyes.queueProcessor = qp;

                // Heads - Bone_Rotation
                eyes.BuildHeadTemplate(Eyes.HeadTemplates.Bone_Rotation_XY);
                eyes.heads[0].expData.controllerVars[0].bone = FindTransform(eyes.characterRoot, head);
                eyes.headTargetOffset.y = 0.052f;
                eyes.FixAllTransformAxes(ref eyes.heads, false);
                eyes.FixAllTransformAxes(ref eyes.heads, true);

                // Eyes - Bone_Rotation
                eyes.BuildEyeTemplate(Eyes.EyeTemplates.Bone_Rotation);
                eyes.eyes[0].expData.controllerVars[0].bone = FindTransform(eyes.characterRoot, eyeL);
                eyes.eyes[1].expData.controllerVars[0].bone = FindTransform(eyes.characterRoot, eyeR);
                eyes.FixAllTransformAxes(ref eyes.eyes, false);
                eyes.FixAllTransformAxes(ref eyes.eyes, true);

                // Eyelids - Bone_Rotation
                eyes.BuildEyelidTemplate(Eyes.EyelidTemplates.BlendShapes); // includes left/right eyelid
                eyes.SetEyelidShapeSelection(Eyes.EyelidSelection.Upper);
                float blinkMax = 1f;
                switch (lod)
                {
                case 0:         // Crowd
                    body = "^h_dds_.*crowd.*$";
                    break;

                case 1:             // low
                    body = "^h_dds_.*low.*$";
                    break;

                case 2:             // mid
                    body = "^h_dds_.*mid.*$";
                    break;

                case 3:             // high
                    body = "^h_dds_.*high.*$";
                    break;
                }
                // Left eyelid
                eyes.eyelids[0].referenceIdx = 0;
                eyes.eyelids[0].expData.controllerVars[0].smr        = FindTransform(eyes.characterRoot, body).GetComponent <SkinnedMeshRenderer>();
                eyes.eyelids[0].expData.controllerVars[0].blendIndex = FindBlendIdx(eyes.eyelids[0].expData.controllerVars[0].smr, blinkL);
                eyes.eyelids[0].expData.controllerVars[0].maxShape   = blinkMax;
                // Right eyelid
                eyes.eyelids[1].referenceIdx = 1;
                eyes.eyelids[1].expData.controllerVars[0].smr        = eyes.eyelids[0].expData.controllerVars[0].smr;
                eyes.eyelids[1].expData.controllerVars[0].blendIndex = FindBlendIdx(eyes.eyelids[1].expData.controllerVars[0].smr, blinkR);
                eyes.eyelids[1].expData.controllerVars[0].maxShape   = blinkMax;

                // Initialize the Eyes module
                eyes.Initialize();
            }
        }
Пример #12
0
 /// <summary>
 /// Initialize
 /// </summary>
 /// <param name="queue"></param>
 /// <param name="settings"></param>
 public NotificationAccountService(QueueProcessor <NotificationMessage> queue, NotificationSettings settings)
     : base(queue, settings)
 {
 }
Пример #13
0
 /// <summary>
 /// Initialize.
 /// </summary>
 /// <param name="queue"></param>
 /// <param name="settings"></param>
 public NotificationServiceBase(QueueProcessor <NotificationMessage> queue, NotificationSettings settings)
 {
     _settings = settings;
     _queue    = queue;
 }
        internal static QueueProcessor CreateQueueProcessor(CloudQueue queue, CloudQueue poisonQueue, TraceWriter trace, IQueueConfiguration queueConfig, EventHandler poisonQueueMessageAddedHandler)
        {
            QueueProcessorFactoryContext context = new QueueProcessorFactoryContext(queue, trace, queueConfig, poisonQueue);

            QueueProcessor queueProcessor = null;
            if (HostQueueNames.IsHostQueue(queue.Name) && 
                string.Compare(queue.Uri.Host, "localhost", StringComparison.OrdinalIgnoreCase) != 0)
            {
                // We only delegate to the processor factory for application queues,
                // not our built in control queues
                // We bypass this check for local testing though
                queueProcessor = new QueueProcessor(context);
            }
            else
            {
                queueProcessor = queueConfig.QueueProcessorFactory.Create(context);
            }

            if (poisonQueueMessageAddedHandler != null)
            {
                queueProcessor.MessageAddedToPoisonQueue += poisonQueueMessageAddedHandler;
            }

            return queueProcessor;
        }