locked
Composite activity design question RRS feed

  • Question

  • I'm currently working on a design that would utilize a composite activity that contains an InvokeMethodActivity and an EventSinkActivity. The purpose of the composite activity is to encapsulate the sending of a message to a queue and then to await a response on a separate queue. This composite activity will represent the base class for many higher-level activities that will operate in this manner. Therefore, a workflow will be comprised of many of these types of activities.

    In the examples that I've seen for this pattern (InvokeMethod / EventSink), the event sink uses a service implementation that lives in the host process.

    In my case where there are several event sinks (potentially running in parallel), would a single service implementation living in the host process service all activity instances for a workflow? And if so, would it require use of the CorrelationReference to differentiate between activities?

    Or would I instantiate a service instance per activity in order to have that instance service the associated activity in a one-to-one basis? What's the best pattern to apply here?

    Thanks in advance for any help you can give in this area.
    Tuesday, November 29, 2005 8:13 PM

Answers

  • Andy,

    You are correct - only one instance of a service should be added to the workflow runtime container.  Only one instance is used to service all workflow instances. 

    If you use an InvokeMethod and EventSink, you need to ensure that each composite has its own correlation reference; this can be done by adding the correlation reference to the composite activity.  The invoke method could create a guid (or use some other unique token) so that the follower event sink can be routed to.

    Composite
       InvokeMethod (initializes correlation)
       EventSink (follows corrleation)

    I would also recommend taking a look at the Communications\SimpleInput sample included in the SDK.  Depending on the nature of the composite you're trying to build, you may want to also consider directly interacting with the workflow queues.

    Hope this helps you get started,
    Arjun
    Tuesday, November 29, 2005 8:48 PM