Sunday, July 11, 2010

Implementing work for ExecutionServe

While the design goal of "VeroRight" is to accomplish as much application development through configuration as possible, some operations are complex and simply require coding. For those that are also execution intensive or performance sensitive, ExecutionServe provides a remote service-based execution environment within which submitted work can be executed asynchronously for load balancing across servers.

Units of work are implemented for execution within ExecutionServe by simply extending a base class that hides all underlying details of ExecutionServe's execution environment:
  1. Derive your worker class from the Worker class within Entities.dll (built from svn://[repositoryAddress]/[company]/WorkflowServices/WorkflowServices.sln)
  2. Decorate it with the DataContract attribute
  3. Add properties decorated with the DataMember attribute
  4. Override the doWork() method with your long running implementation.

The following example code snippet is from svn:// [repositoryAddress]/[company]/WorkflowServices/SampleCalculator:

  
    [DataContract]
    public class LongerRunningCalculator : Worker
    {
        [DataMember]
        public string Param1 { get; set; }

        [DataMember]
        public string Param2 { get; set; }

        protected override DoWorkReturnParameter doWork()
        {
            System.Threading.Thread.Sleep(14400000); //4 hours

            DoWorkReturnParameter returnParam = new DoWorkReturnParameter();
            returnParam.Message = "return value";
            returnParam.Status = "status value;

            return returnParam;
        }
    }

This example class can now be instantiated, its DataMember properties set, and then serialized so it can be supplied to a remote ExecutionServe's IExecutionService.executeAsync() operation for execution of its doWork() method. It will also be automatically serialized again and asynchronously returned to the caller  after its doWork() method completes so that any changes to its DataMember properties are available after completion. 

"VeroServe Workflow" use of ExecutionServe will be discussed in a subsequent post.

No comments:

Post a Comment