示例#1
0
        internal void ProcessesQueuedAsynchronousEvents()
        {
            Queue messages = this.GetQueue("*PendingNotifications").Messages;

            while (messages.Count > 0)
            {
                KeyValuePair <IComparable, EventQueueState> pair = (KeyValuePair <IComparable, EventQueueState>)messages.Dequeue();
                WorkflowTrace.Runtime.TraceInformation("Queuing Service: Processing delayed message notification '{0}'", new object[] { pair.Key.ToString() });
                for (int i = 0; (this.messageArrivalEventHandlers != null) && (i < this.messageArrivalEventHandlers.Count); i++)
                {
                    WorkflowQueuingService service = this.messageArrivalEventHandlers[i];
                    if (service.persistedQueueStates.ContainsKey(pair.Key))
                    {
                        EventQueueState queue = service.GetQueue(pair.Key);
                        if (queue.Enabled)
                        {
                            service.NotifyAsynchronousSubscribers(pair.Key, queue, 1);
                        }
                    }
                }
                this.NotifyAsynchronousSubscribers(pair.Key, pair.Value, 1);
            }
        }
        public void RegisterForQueueItemAvailable(IActivityEventListener <QueueEventArgs> eventListener, string subscriberQualifiedName)
        {
            if (eventListener == null)
            {
                throw new ArgumentNullException("eventListener");
            }

            lock (qService.SyncRoot)
            {
                EventQueueState qState = qService.GetQueueState(this.queueName);
                ActivityExecutorDelegateInfo <QueueEventArgs> subscriber = new ActivityExecutorDelegateInfo <QueueEventArgs>(eventListener, qService.CallingActivity);
                if (subscriberQualifiedName != null)
                {
                    subscriber.SubscribedActivityQualifiedName = subscriberQualifiedName;
                }
                qState.AsynchronousListeners.Add(subscriber);
                WorkflowTrace.Runtime.TraceEvent(TraceEventType.Information, 0, "WorkflowQueue:QueueItemAvailable subscribe for activity '{0}' with context Id {1}", subscriber.ActivityQualifiedName, subscriber.ContextId);

                if (qState.AsynchronousListeners.Count == 1)
                {
                    qService.NotifyAsynchronousSubscribers(this.queueName, qState, qState.Messages.Count);
                }
            }
        }
        internal void ProcessesQueuedAsynchronousEvents()
        {
            Queue q = GetQueue(pendingNotification).Messages;

            while (q.Count > 0)
            {
                KeyValuePair <IComparable, EventQueueState> pair = (KeyValuePair <IComparable, EventQueueState>)q.Dequeue();
                // notify message arrived subscribers
                WorkflowTrace.Runtime.TraceInformation("Queuing Service: Processing delayed message notification '{0}'", pair.Key.ToString());
                for (int i = 0; messageArrivalEventHandlers != null && i < messageArrivalEventHandlers.Count; ++i)
                {
                    WorkflowQueuingService service = this.messageArrivalEventHandlers[i];
                    if (service.persistedQueueStates.ContainsKey(pair.Key))
                    {
                        EventQueueState qState = service.GetQueue(pair.Key);
                        if (qState.Enabled)
                        {
                            service.NotifyAsynchronousSubscribers(pair.Key, qState, 1);
                        }
                    }
                }
                NotifyAsynchronousSubscribers(pair.Key, pair.Value, 1);
            }
        }