views:

62

answers:

1
WorkflowRuntime workflowRuntime = new WorkflowRuntime();

 ExternalDataExchangeService dataExchangeService;
 dataExchangeService = new ExternalDataExchangeService();
 workflowRuntime.AddService(dataExchangeService);

 PaymentProcessingService paymentProcessing;
 paymentProcessing = new PaymentProcessingService();
 dataExchangeService.AddService(paymentProcessing);

With the code above, our application can use paymentProcessing.RaiseXXXXEvent to interactive with the workflow instance. My question is : What's the principle to implement such a mechanism. I think this is a kind of Event Driven Pattern, but how can I implement this mechanism and why ? Please point me the direction or any references are appreciated.

By the way, is there the mechanism in jBPM ? Does jBPM include sequence workflow and state machine workflow like window workflow foundation ?

Thanks !

A: 

WF defines a set of core workflow services that handle thread scheduling, workflow persistence, transactions, and workflow tracking. The designers of WF could have embedded the implementation of these services in the runtime engine itself, but they wisely chose to externalize them, placing their implementations in pluggable services. This places you in control. You decide which services to use (some are optional) and which implementation to use for each service.

WF also supports another kind of service known as a local service (sometimes called a data exchange service). This is a service that you design and implement yourself. A local service can serve just about any purpose, but one general use is to facilitate communications between workflow instances and the host application. In contrast with this, core workflow services each have a purpose (for example, persistence, tracking) that has been defined by Microsoft. You can develop alternate implementations for each core service, but that doesn’t change their defined purpose.

To have your local service available to your workflow instance. There are several methods to do this. The simplest would be to use the CallExternalMethodActivity and configure it.

Also the service should have an interface and decorated with [ExternalDataExchange].

If you are looking at writing your own implementation of a core service, here is a link that describe how to provide your own core workflow service.

http://msdn.microsoft.com/en-us/library/ms734705(v=VS.90).aspx

pdiddy
I think you didn't get my meaning, I know what you said, but my problem is how can MS implement the "pluggable services", any sample code ?
MemoryLeak
you are looking to write your own implementation of the core services? Or you are looking at how to write a local service?
pdiddy
Or are you looking how to raise an event so the workflow handles it?
pdiddy
write my own implementation of the core services.
MemoryLeak
here is a link to write your own custom workflow tracking service. http://msdn.microsoft.com/en-us/library/ms735912(VS.90).aspx. What core service are you looking at providing your own.
pdiddy
here is a link to create your custom core services : http://msdn.microsoft.com/en-us/library/ms734705(v=VS.90).aspx
pdiddy