Replicator and correlation

Has anyone successfully used the replicator with a sequence of invoke method/event sink activities

I've tried adapting various samples but can't get this to work. I have created a ChildInitialize method to access the invoke and event activities and set their properties but the property I can't set is the CorrelationReference as this need to be set to be an ActivityBind.

If anyone has a sample of this then it would be most gratefully received.

Much obliged,

David.



Answer this question

Replicator and correlation

  • Smitha_Vijayan

    Arjun,

    Thank you for the reply.

    I'm using the replicator in parallel mode.

    Each correlation reference is initialized by the InvokeMethod activity (the correlation set consists of a Guid that is generated by the invoke method custom code).

    What I don't understand about your proposal, to encapsulate the child activities in a custom sequence activity, is how to bind the correlation reference to an instance of the CorrelationReference object. In the child initializor event handler I can create a new instance of a correlation reference but I don't see how I can bind it to the activities dependency properties.

    This is how I tried to do it with a sequence of my invoke and event activities:-




    private void ReplicatorInitializer(object sender, ReplicatorEventArgs args)
    {
        ArrayList children = new ArrayList();
        children.Add("Seller1");
        children.Add("Seller2");
        args.Children = children;

        args.ExecutionType = ExecutionType.Parallel;
    }

    private void ChildInitializer(object sender, ReplicatorChildEventArgs args)
    {
        MyInvoke send = (args.Activity as Sequence).Activities[0] as MyInvoke;
        MyEvent receive = (args.Activity as Sequence).Activities[1] as MyEvent;
        string seller = args.InstanceData as string;  
        CorrelationReference correlationReference = new CorrelationReference();
        send.CorrelationReference = correlationReference;
        receive.CorrelationReference = correlationReference; 
    }


     



  • Looob

    David,

    Are you using the replicator in parallel or sequential mode   Also, how are your correlations initialized   If you are initializing multiple correlations within your replicated instances, each instance needs to have a unique correlation reference.  A good way to do this is by encapsulating your replicator children into a custom activity.

    Also, keep in mind that an event sink cannot be used to initialize the correlation within a replicated instance. 

    Here's how a typical messaging scenario with a replicator might look like:

    Replicator
       Custom Sequence Activity [with correlation reference & any other properties]
          MethodInvoke activity, initializing correlation
          EventSink, correlation follower
          etc


    Hope this gets you started,
    Arjun

  • Replicator and correlation