locked
Context Correlation initializer / Request-Reply Correlation initializer RRS feed

  • Question

  • My guess is that these two correlation initializers are only useful for context based routing using the existing context bindings. However, it is not clear for me what is the main difference between them, and when I should use each one (the main scenario for them). Could someone provide more information about this ?

    Thanks
    Pablo.
    Pablo Cibraro - http://weblogs.asp.net/cibrax
    Saturday, November 14, 2009 11:03 AM

Answers

  • There are 3 kinds of Correlation Initializers, QueryCorrelationInitializer, RequestReplyCorrelationInitializer and ContextCorrelationInitializer.

    RequestReplyCorelationInitializer (RRCI), is used when you want to send a two way message over a channel. For an example of how to use it properly you can create a new WF service project using Visual Studio 2010. The only times that it can be used are on either a receive or a send activity that has been paired with the matching reply activity. In this case the 'correlation' that is getting mapped by the correlation initializer is the reference to the channel that should be used to send the response (note that since we are keeing a reference to a channel, RRCI causes you to enter a no-persist zone, unlike the other corr. Initializers.

    ContextCorrelationInitializer (CTXCI), as you correctly guessed is used to map a context id to a workflow instance, and is meant for being used alongside the Context bindings.  This initializer maps the context id to the workflow instance so that ID can be used to correlate another receive later on. ContextCorrelationInitializer should be added to the receive on the service side, and to the receive reply on the client side. The typical pattern for using it on a client would be:

    Send
    ReceiveReply (has a CTXCI)
    Send (CorrelatesWith the same handle that the CTXCI mapped, so that it sends the same ID)
    ...

    And then the Service side would look something like:

    Receive (has a CTXCI)
    SendReply
    Receive (CorrelatesWith the same handle as the CTXCI)


    You didnt ask about it, but just to be complete (and since it may make more sense to compare these to one you already know), Finally there is a QueryCorrelationInitializer (QCI), which is used to map the result of an XPath query to the instance. This is used the exact same way as CTXCI, but instead of using an automatically generated id, and a correlation on the client side, the correlation is only handled on the service side, and maps some piece of data from your message to the workflow instance. The typical pattern for the service here would be:

    Receive (has a QCI)
    [SendReply] (optional)
    Receive (correlatesWith the same handle as the QCI).

    And the client doesnt matter. Note that unlike CTXCI, with a QCI you dont need to start with a two way message.
    Tuesday, November 24, 2009 8:54 PM

All replies

  • There are 3 kinds of Correlation Initializers, QueryCorrelationInitializer, RequestReplyCorrelationInitializer and ContextCorrelationInitializer.

    RequestReplyCorelationInitializer (RRCI), is used when you want to send a two way message over a channel. For an example of how to use it properly you can create a new WF service project using Visual Studio 2010. The only times that it can be used are on either a receive or a send activity that has been paired with the matching reply activity. In this case the 'correlation' that is getting mapped by the correlation initializer is the reference to the channel that should be used to send the response (note that since we are keeing a reference to a channel, RRCI causes you to enter a no-persist zone, unlike the other corr. Initializers.

    ContextCorrelationInitializer (CTXCI), as you correctly guessed is used to map a context id to a workflow instance, and is meant for being used alongside the Context bindings.  This initializer maps the context id to the workflow instance so that ID can be used to correlate another receive later on. ContextCorrelationInitializer should be added to the receive on the service side, and to the receive reply on the client side. The typical pattern for using it on a client would be:

    Send
    ReceiveReply (has a CTXCI)
    Send (CorrelatesWith the same handle that the CTXCI mapped, so that it sends the same ID)
    ...

    And then the Service side would look something like:

    Receive (has a CTXCI)
    SendReply
    Receive (CorrelatesWith the same handle as the CTXCI)


    You didnt ask about it, but just to be complete (and since it may make more sense to compare these to one you already know), Finally there is a QueryCorrelationInitializer (QCI), which is used to map the result of an XPath query to the instance. This is used the exact same way as CTXCI, but instead of using an automatically generated id, and a correlation on the client side, the correlation is only handled on the service side, and maps some piece of data from your message to the workflow instance. The typical pattern for the service here would be:

    Receive (has a QCI)
    [SendReply] (optional)
    Receive (correlatesWith the same handle as the QCI).

    And the client doesnt matter. Note that unlike CTXCI, with a QCI you dont need to start with a two way message.
    Tuesday, November 24, 2009 8:54 PM
  • Very useful information, this is exactly what I was looking for. Thank you very much!!.
    Pablo Cibraro - http://weblogs.asp.net/cibrax
    Friday, November 27, 2009 5:08 PM
  • Do I need to install or update anything to get ContextCorrelation working in .NET 4.0 b2. I'm creating a client and service exactly as you say and even programmed it out as in http://msdn.microsoft.com/en-us/library/ee358724%28VS.100%29.aspx but I can't get it to work. I keep getting the error message 'Activity with operation name '<Operation>' has a CorrelatesWith handle that is not initialized.'


    Wednesday, December 16, 2009 1:37 PM
  • Hi Darran, please correct me if I'm wrong.

    In the Content based Correlation, we have to choose the xpath query to map the data from the message that the Client sends to the RECEIVE activity to a Global variable of type CorrelationHandle. CorrelatioHandle is a Collection type which can hold the data extracted from the message.

    And, when next RECEIVE activity is called by the same client, the passed-in values are evaluated against this CorrelationHandle Collection and enables the Correlation.


    One more question to you....Can you pls. eloborate on how the CorrelatioHandle plays its role in CTXCI and RRCI?

    thanks
    Bhaskar
    Monday, February 1, 2010 9:18 AM