Why does ReceiveAndSendReply use a correlation initializer?

226 Views Asked by At

If I use the ReceiveAndSendReply activity factory, I get a Receive activity, a SendReply activity, and a request-reply correlation initializer on the Receive activity using a CorrelationHandle.

What is this correlation needed for? According to Request-Reply Correlation:

A Receive/SendReply pair is used to implement a two-way operation in a workflow service. The runtime uses request-reply correlation to ensure that the reply is dispatched to the correct caller. When a workflow is hosted using WorkflowServiceHost, which is the case for workflow services, then the default correlation initialization is sufficient.

and

While the Receive activity can only be used in a workflow service hosted by WorkflowServiceHost, Send and the Send/ReceiveReply pair can be used in any workflow that must invoke a method on a Web service.

If Receive/SendReply can only be used in a WorkflowServiceHost, and no explicit request-reply correlation initialization is needed in a WorkflowServiceHost, then can I simply remove the correlation initializer and handle? Or are there some benefits that I'm not seeing?

I'm not asking about the SendAndReceiveReply factory. That also uses a request-reply correlation initializer, but I think I can understand the need for it there.

I'm just getting started with Workflow Foundation, so please don't assume I've already ruled out any obvious answers. I've tried to, but I may well have overlooked some. The page I linked to also contains an example of a Receive/SendReply pair with an explicit correlation initializer. I'm not seeing the benefit there either.

0

There are 0 best solutions below