Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FollowerQueueCreator.cs « LocalService « System.Workflow.Activities « referencesource « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3db7b1ea94a15c959a5c1b10990e9142fd4b217b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#region Using directives

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Collections;
using System.Reflection;
using System.Runtime.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
using System.Runtime.Remoting.Messaging;

#endregion

namespace System.Workflow.Activities
{
    [Serializable]
    internal sealed class FollowerQueueCreator : IActivityEventListener<QueueEventArgs>
    {
        string followerOperation;
        object sync = new object();

        internal FollowerQueueCreator(string operation)
        {
            this.followerOperation = operation;
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;
            FollowerQueueCreator equalsObject = obj as FollowerQueueCreator;
            if (this.followerOperation == equalsObject.followerOperation)
                return true;
            return false;
        }
        public override int GetHashCode()
        {
            return this.followerOperation.GetHashCode();
        }

        #region IActivityEventListener<QueueEventArgs> Members

        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);
                }
            }
        }

        #endregion
    }
}