예제 #1
0
        private static void CreateFollowerEntry(IServiceProvider context, Type interfaceType, string followermethodName, string initializermethodName)
        {
            if (!CorrelationResolver.IsInitializingMember(interfaceType, initializermethodName, null))
            {
                return;
            }

            WorkflowQueuingService queueSvcs = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService));
            FollowerQueueCreator   follower  = new FollowerQueueCreator(followermethodName);

            WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "Creating follower {0} on initializer {1}", interfaceType.Name + followermethodName, interfaceType.Name + initializermethodName);

            ICollection <CorrelationProperty> corrValues = CorrelationResolver.ResolveCorrelationValues(interfaceType, initializermethodName, null, true);
            EventQueueName key = new EventQueueName(interfaceType, initializermethodName, corrValues);
            WorkflowQueue  initializerQueue = null;

            if (queueSvcs.Exists(key))
            {
                initializerQueue = queueSvcs.GetWorkflowQueue(key);
            }
            else
            {
                // traversed follower before initializer
                initializerQueue         = queueSvcs.CreateWorkflowQueue(key, true);
                initializerQueue.Enabled = false;
            }

            initializerQueue.RegisterForQueueItemArrived(follower);
        }
예제 #2
0
        internal static IComparable ResolveQueueName(Activity activity, Type interfaceType, string methodName)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (interfaceType == null)
            {
                throw new ArgumentNullException("interfaceType");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }

            // resolver will check for an explicit correlation provider,
            // if none present this will return an uncorrelated provider.
            // note, an uncorrelated methodName will always be an initializer
            if (CorrelationResolver.IsInitializingMember(interfaceType, methodName, null))
            {
                ICollection <CorrelationProperty> corrvalues = CorrelationResolver.ResolveCorrelationValues(interfaceType, methodName, null, true);
                return(new EventQueueName(interfaceType, methodName, corrvalues));
            }

            CorrelationToken reference = GetCorrelationToken(activity);

            if (!reference.Initialized)
            {
                return(null);
            }

            return(new EventQueueName(interfaceType, methodName, reference.Properties));
        }
예제 #3
0
        internal static void InvalidateCorrelationToken(Activity activity, Type interfaceType, string methodName, object[] messageArgs)
        {
            object correlationProvider = CorrelationResolver.GetCorrelationProvider(interfaceType);

            if (correlationProvider is NonCorrelatedProvider)
            {
                return;
            }

            CorrelationToken reference = GetCorrelationToken(activity);
            ICollection <CorrelationProperty> correlationvalues = CorrelationResolver.ResolveCorrelationValues(interfaceType, methodName, messageArgs, false);

            if (!CorrelationResolver.IsInitializingMember(interfaceType, methodName, messageArgs))
            {
                if (!reference.Initialized)
                {
                    throw new InvalidOperationException(SR.GetString(SR.Error_CorrelationNotInitialized, reference.Name, activity.QualifiedName));
                }
                ValidateCorrelation(reference.Properties, correlationvalues, reference.Name, activity);
                return;
            }

            // invalidate correlation token if methodName is an initializer
            reference.Initialize(activity, correlationvalues);
        }
        internal static IComparable ResolveQueueName(Activity activity, Type interfaceType, string methodName)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (interfaceType == null)
            {
                throw new ArgumentNullException("interfaceType");
            }
            if (methodName == null)
            {
                throw new ArgumentNullException("methodName");
            }
            if (CorrelationResolver.IsInitializingMember(interfaceType, methodName, null))
            {
                return(new EventQueueName(interfaceType, methodName, CorrelationResolver.ResolveCorrelationValues(interfaceType, methodName, null, true)));
            }
            CorrelationToken correlationToken = GetCorrelationToken(activity);

            if (!correlationToken.Initialized)
            {
                return(null);
            }
            return(new EventQueueName(interfaceType, methodName, correlationToken.Properties));
        }
예제 #5
0
        private EventQueueName GetKey(object[] eventArgs)
        {
            bool provideInitializerTokens = CorrelationResolver.IsInitializingMember(this.proxiedType, this.eventName, eventArgs);

            ICollection <CorrelationProperty> predicates = CorrelationResolver.ResolveCorrelationValues(this.proxiedType, this.eventName, eventArgs, provideInitializerTokens);

            return(new EventQueueName(this.proxiedType, this.eventName, predicates));
        }
 void IActivityEventListener <QueueEventArgs> .OnEvent(object sender, QueueEventArgs args)
 {
     lock (this.sync)
     {
         WorkflowQueue  queue     = (WorkflowQueue)sender;
         EventQueueName queueName = (EventQueueName)queue.QueueName;
         WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "FollowerQueueCreator: initialized on operation {0} for follower {1}", new object[] { queueName.InterfaceType.Name + queueName.MethodName, this.followerOperation });
         IMethodMessage message = queue.Peek() as IMethodMessage;
         ICollection <CorrelationProperty> propertyValues = CorrelationResolver.ResolveCorrelationValues(queueName.InterfaceType, queueName.MethodName, message.Args, false);
         EventQueueName name2 = new EventQueueName(queueName.InterfaceType, this.followerOperation, propertyValues);
         if (!queue.QueuingService.Exists(name2))
         {
             WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "FollowerQueueCreator::CreateQueue creating q {0}", new object[] { name2.GetHashCode() });
             queue.QueuingService.CreateWorkflowQueue(name2, true);
         }
     }
 }
 internal static void InvalidateCorrelationToken(Activity activity, Type interfaceType, string methodName, object[] messageArgs)
 {
     if (!(CorrelationResolver.GetCorrelationProvider(interfaceType) is NonCorrelatedProvider))
     {
         CorrelationToken correlationToken = GetCorrelationToken(activity);
         ICollection <CorrelationProperty> followerProperties = CorrelationResolver.ResolveCorrelationValues(interfaceType, methodName, messageArgs, false);
         if (!CorrelationResolver.IsInitializingMember(interfaceType, methodName, messageArgs))
         {
             if (!correlationToken.Initialized)
             {
                 throw new InvalidOperationException(SR.GetString("Error_CorrelationNotInitialized", new object[] { correlationToken.Name, activity.QualifiedName }));
             }
             ValidateCorrelation(correlationToken.Properties, followerProperties, correlationToken.Name, activity);
         }
         else
         {
             correlationToken.Initialize(activity, followerProperties);
         }
     }
 }
예제 #8
0
        void IActivityEventListener <QueueEventArgs> .OnEvent(object sender, QueueEventArgs args)
        {
            lock (sync)
            {
                WorkflowQueue queue = (WorkflowQueue)sender;

                // create the queue after extracting the correlation values from the message
                EventQueueName staticId = (EventQueueName)queue.QueueName;
                WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "FollowerQueueCreator: initialized on operation {0} for follower {1}", staticId.InterfaceType.Name + staticId.MethodName, this.followerOperation);

                IMethodMessage message = queue.Peek() as IMethodMessage;

                ICollection <CorrelationProperty> corrValues = CorrelationResolver.ResolveCorrelationValues(staticId.InterfaceType, staticId.MethodName, message.Args, false);

                EventQueueName queueName = new EventQueueName(staticId.InterfaceType, this.followerOperation, corrValues);
                if (!queue.QueuingService.Exists(queueName))
                {
                    WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "FollowerQueueCreator::CreateQueue creating q {0}", queueName.GetHashCode());
                    queue.QueuingService.CreateWorkflowQueue(queueName, true);
                }
            }
        }
 private static void CreateFollowerEntry(IServiceProvider context, Type interfaceType, string followermethodName, string initializermethodName)
 {
     if (CorrelationResolver.IsInitializingMember(interfaceType, initializermethodName, null))
     {
         WorkflowQueuingService service       = (WorkflowQueuingService)context.GetService(typeof(WorkflowQueuingService));
         FollowerQueueCreator   eventListener = new FollowerQueueCreator(followermethodName);
         WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "Creating follower {0} on initializer {1}", new object[] { interfaceType.Name + followermethodName, interfaceType.Name + initializermethodName });
         ICollection <CorrelationProperty> propertyValues = CorrelationResolver.ResolveCorrelationValues(interfaceType, initializermethodName, null, true);
         EventQueueName queueName     = new EventQueueName(interfaceType, initializermethodName, propertyValues);
         WorkflowQueue  workflowQueue = null;
         if (service.Exists(queueName))
         {
             workflowQueue = service.GetWorkflowQueue(queueName);
         }
         else
         {
             workflowQueue         = service.CreateWorkflowQueue(queueName, true);
             workflowQueue.Enabled = false;
         }
         workflowQueue.RegisterForQueueItemArrived(eventListener);
     }
 }