proficy* workflow - kerrco automation · if adam is not installed in favour of a local directory,...

23
Proficy* Workflow Powered by Proficy SOA B EST P RACTICES Version 1.1 May 2011

Upload: vanquynh

Post on 06-Aug-2018

233 views

Category:

Documents


0 download

TRANSCRIPT

Proficy* Workflow Powered by Proficy SOA

BEST PRACTICES

Version 1.1 May 2011

All rights reserved. No part of this publication may be reproduced in any form or by any electronic or mechanical means, including photocopying and recording, without permission in writing from GE Intelligent Platforms, Inc.

Disclaimer of Warranties and Liability

The information contained in this manual is believed to be accurate and reliable. However, GE Intelligent Platforms, Inc. assumes no responsibilities for any errors, omissions or inaccuracies whatsoever. Without limiting the foregoing, GE Intelligent Platforms, Inc. disclaims any and all warranties, expressed or implied, including the warranty of merchantability and fitness for a particular purpose, with respect to the information contained in this manual and the equipment or software described herein. The entire risk as to the quality and performance of such information, equipment and software, is upon the buyer or user. GE Intelligent Platforms, Inc. shall not be liable for any damages, including special or consequential damages, arising out of the use of such information, equipment and software, even if GE Intelligent Platforms, Inc. has been advised in advance of the possibility of such damages. The use of the information contained in the manual and the software described herein is subject to GE Intelligent Platforms, Inc. standard license agreement, which must be executed by the buyer or user before the use of such information, equipment or software.

Trademarks

© 2010, GE Intelligent Platforms, Inc. All rights reserved. * Trademark of GE Intelligent Platforms, Inc. All other brands or names are property of their respective holders. Any other trademarks referenced herein are used solely for purposes of identifying compatibility with the products of GE Intelligent Platforms, Inc.

Notice

GE Intelligent Platforms, Inc. reserves the right to make improvements to the products described in this publication at any time and without notice. We want to hear from you. If you have any comments, questions, or suggestions about our documentation, send them to the following email address:

[email protected]

Table of Contents

i

Table of Contents Installation _______________________________________ 1

ADAM 1 Workflow Performance _____________________________ 2

Persistence 2 Memory 4 Tracking Configuration 5 Subprocesses 6 Activities 8

Start Workflow and Start Schedule 8 While and ForEach 8 Write 9 If/Else 11 Form Events 12

Forms ___________________________________________ 13 Workflow Customization ____________________________ 15

Using Existing .NET Libraries 15 Custom Proficy Service 15 Custom Workflow Activity 17 Call from Code Activity 18

Installation

1

Installation

ADAM

If ADAM is not installed in favour of a local directory, then the Proficy Publisher service does not need to run.

2 Proficy* Workflow

Workflow Performance

This section provides more information about some features, and contains suggestions for improving the performance of your workflows.

NOTE: Each recommendation is rated HIGH, MEDIUM, and LOW to indicate the level of importance and impact on your workflow.

Persistence

Overview

The execution engine records internal tracking data that includes the state information associated with a running workflow instance. The execution engine persists the workflow instance state when a subprocess completes. The persisted state can be used to recover and restart a workflow instance from failure conditions, or if it was stopped. If a workflow is stopped normally, the postsubprocess, postprocess, and unload steps run before the instance stops (they will not run if the server crashes). The workflow instance can continue from the start of the current subprocess by using the restart command. When this happens, the instance restarts by running the load, preprocess, and presubprocess steps. Then it restarts at the beginning of the subprocess that was running before the workflow stopped.

You can significantly improve the performance of your workflow by implementing one or all of the following recommendations:

Disable persistence (HIGH)

Decrease the number of persistence points (MEDIUM)

Reduce activities (HIGH)

Workflow Performance

3

Disabling Persistence

Recommendation (HIGH): Disable persistence if you do not need instances of the workflow to recover after a server restart.

Workflows are automatically configured to have persistence enabled, saving the current state of the instance to the Workflow database. This save process is a slow operation, impacting workflow performance as it moves from one subprocess to the next. This process is also CPU-intensive, so it can have a negative impact on the performance of other running workflow instances.

Decreasing Persistence Points

Recommendation (MEDIUM): Decrease the number of persistence points in a workflow by reducing the number of subprocesses.

If you choose to enable persistence, use as few subprocesses as possible. Since the workflow instance state is saved after each subprocess completes, unnecessary subprocesses can negatively impact the performance of the instance and any other running workflow instances.

Reducing Activities

Recommendation (HIGH): Reduce the number of activities in a workflow.

A persisted workflow saves the state of all workflow objects. Reducing the number of activities in a workflow decreases the time needed to save the workflow instance state.

4 Proficy* Workflow

Memory

Overview

Workflows consume memory at run time, and all objects that are part of that workflow contribute to that memory consumption.

You can significantly improve the performance of your workflow by implementing one or all of the following recommendations:

Reduce concurrent workflow instances (MEDIUM)

Reduce activities (MEDIUM)

Reducing Concurrent Workflow Instances

Recommendation (MEDIUM): Reduce the number of concurrently running workflow instances.

Every running workflow instance consumes a significant amount of server memory, even if they are instances of the same workflow definition. For example, if you have several background workflow instances that run periodically and have similar logic, combine them into a single workflow instance.

Reducing Activities

Recommendation (MEDIUM): Reduce the number of activities in a workflow.

Each activity in a workflow uses memory at run time, including the execution state of all properties, parameters, and local variables.

Workflow Performance

5

Tracking Configuration

Overview

You can track workflow, subprocess, and/or schedule data while a workflow is running.

On a workflow or schedule, the system records task data for the corresponding workflow instances. It can be used to generate reports on historical data, such as task and task step durations, expiry, and performing user/location. It also allows a user of the Task List display to view previously completed tasks.

On a subprocess, specific local variables can be tracked. These variables are tracked to relate tasks to data in other models in the reporting database.

You can significantly improve the performance of your workflow by implementing one or all of the following recommendations:

Disable tracking (MEDIUM)

Track at the appropriate levels (MEDIUM)

Select a minimal set of tracked local variables (LOW)

Disabling Tracking

Recommendation (MEDIUM): Disable tracking for a workflow or schedule if you do not need task instance history for the Task List display or reporting.

If tracking is enabled, then task data is saved at certain points to the workflow database. This process impacts the execution speed of the workflow.

6 Proficy* Workflow

Tracking Appropriate Levels

Recommendation (MEDIUM): Enable tracking at the appropriate level.

Tracking at both the process and subprocess levels results in task data being saved more often. Therefore, to improve performance, ensure you are tracking at the appropriate levels:

process level if historical task step data is not required

subprocess level to view a workflow's task history in the Task List display

Selecting Local Variables to Track

Recommendation (LOW): Select a minimal set of local variable for tracking.

In a subprocess, you can include specific local variables in the tracking data to relate tasks to other data. For example, you can track a work request ID in a local variable for relating task data with a corresponding work request. As a result, the number of local variables that are tracked impacts performance.

Subprocesses

Overview

A subprocess is part of a user-defined process in a workflow, and a workflow must be constructed of one or more subprocess. Each subprocess is a self-contained entity where the majority of the logic is added to run a workflow. Subprocesses group a set of related activities in a workflow and appear as a single task step. They allow you to create a series of steps to accomplish a task, assignment, event-driven, or activated process. The contents of a subprocess consist of activities that can be placed in any order depending on the requirement.

Workflow Performance

7

You can also make a subprocess global, which allows you to develop and store standard and frequently used subprocesses to be reused in various workflows.

Note: When any global resource, such as a subprocess or user activity, is used in a workflow instance, it acts the same as any non-preconfigured resource. As a result, their use does not improve workflow performance.

You can significantly improve the performance of your workflow by implementing one or all of the following recommendations:

Reduce activities (MEDIUM)

Set Visible property (LOW)

Reducing Activities

Recommendation (MEDIUM): Reduce the number of activities in a subprocess improves the subprocess’ starting execution time.

When a subprocess executes, the entire subprocess, including all activities, is copied. The subprocess is copied to allow it to execute repeatedly in the case of a Jump action or continuous workflow setting.

Setting Visible to False

Recommendation (LOW): Set Visible to False for a subprocess if it does not need to appear as a task step in the Task List display.

Some workflows contain subprocesses that do not have any user interaction. These subprocesses do not contain any Form or Status Message activities, and they have set the Manual Start property to False. Because no interaction is required, you can hide the subprocess from the Task List display by setting the Visible property to False. Setting this property improves the subprocess' execution performance and reduces the network traffic between the workflow server and the clients.

8 Proficy* Workflow

Activities

Start Workflow and Start Schedule

Overview

These activities allow a workflow or a schedule to start during the execution of another workflow.

Re-using Workflow Logic

Recommendation (HIGH): Avoid using Start Workflow or Start Schedule as a way to re-use workflow logic.

Use a global subprocess or a global user activity to re-use workflow logic between two different workflows. There is a significant performance overhead with starting a new workflow instance that does not exist with a global subprocess or user activity.

While and ForEach

A ForEach activity repeats the execution of a section of the workflow several times for a number of target instances in a collection, and a While activity repeats the execution of a workflow subsection as long as a specified condition is true. The condition is checked each time the activity begins.

You can significantly improve the performance of your workflow by implementing one or all of the following recommendations:

Reduce activities (HIGH)

Minimize iterations (HIGH)

Use Code activity (LOW)

Workflow Performance

9

Reducing Activities

Recommendation (HIGH): Reduce the number of activities in a loop.

Each time a While or ForEach loop iterates, it creates a copy of all contained activities, including all of the run-time property data for the activities.

Minimizing Iterations

Recommendation (HIGH): Minimize the number of iterations done by looping activities.

Minimize the number of loop iterations to minimize the number of times that the contained activities are copied and executed.

Using the Code Activity

Recommendation (LOW): Use a Code activity to replace loops that are calculating one or more values.

If you are using a While or ForEach loop to process a list to generate one or more values, consider replacing that loop with the equivalent Code activity. This activity performs better due to the copying behaviour of the looping activities.

Write

The Write activity performs a set of writes to workflow variables. The source of each write can be an expression, a bind, or a user-defined absolute value.

Combining Writes

Recommendation (LOW): Combine multiple write activities that are in sequence.

10 Proficy* Workflow

If you have multiple write activities that are in sequence (see Figure 1), combine these into a single Write activity that contains multiple writes (see Figure 2) to reduce execution time and memory usage.

Note: Because the order of writes on a single Write activity is not guaranteed, use two separate write activities if one depends on the result of a previous write.

Figure 1

Figure 2

Workflow Performance

11

If/Else

The If/Else activity changes execution of the workflow to one of multiple exit branches based on the resolution of a condition.

Replacing If/Else with Write

Recommendation (LOW): Replace an If/Else activity with a single Write activity that uses the IF expression function.

If you are using an If/Else activity to calculate one or more values based on a series of conditions (see Figure 3), replace it with a single Write activity (see Figure 4). The Write activity can use the IF expression function to write different values depending on a condition, thereby reducing execution time and memory usage.

Example

If/Else activity with two branches:

Branch 1:

condition = a > 10

writes a value of valid to a local variable

Branch 2:

condition = none

writes a value of invalid to the local variable

Value can be replaced by a single Write activity to the local variable with this expression:

IF(a > 10, “valid”, “invalid”)

12 Proficy* Workflow

Figure 3

Figure 4

Form Events

(HIGH)

Using Form Events to validate form data in workflow logic puts extra load on the workflow server. Though it is easier to write the validation logic in a workflow, the validation should be done in the form itself.

Forms

13

Forms

Forms are displays that are used as activities in workflows, providing a user interface for task steps. A form can display data or allow you to interact with a running process, or both.

You can significantly improve the performance of your forms by implementing one or all of the following recommendations:

Reduce parameters

Bind in the form Control Property

Change the Object property

Bind on controls

Reducing Form Parameters

Recommendation: Minimize the number of form parameters and the size of the form parameter data.

When a form is selected for a Form activity, a property is generated for each parameter on the form. Form parameter data is transferred between the workflow server and the client Task List displays. Large form data can cause delays in the loading of the Task List display or in task change notifications sent to the display.

Binding in the Form Control Property

Recommendation: Do not bind a form control property to an output parameter value.

Binding a control property to an output parameter is not currently supported. Instead, bind the output parameter value to the control property.

14 Proficy* Workflow

Changing the Object Property

Recommendation: Use the DisplayMemberPath property to change the object property that is displayed in collection controls.

By default, collection controls such as ListBox or ComboBox display the collection objects by using the result of the ToString method. This behaviour can be overridden by setting the DisplayMemberPath property to the name of the object property that should be displayed.

Binding on Controls

Recommendation: Do not bind to the IsChecked.Value property on a RadioButton or CheckBox control.

Binding to the IsChecked.Value property is not supported. Instead, bind directly to the IsChecked property.

Workflow Customization

15

Workflow Customization

Using Existing .NET Libraries

There are three ways that an existing .NET library can be exposed to Proficy Workflow and invoked from workflow logic:

Create a custom Proficy service

Create a custom workflow activity

Directly call from a Code activity

Each approach has different advantages that may be more suitable than the others depending on the situation.

Custom Proficy Service

In most cases, the ideal way to expose the .NET library to Proficy Workflow is to create a custom Proficy service and wrap the library. With this approach, you must create an interface for your service that contains the set of methods that workflows can invoke. In addition, you can expose events for use in triggering schedules or Wait for Event activities in workflows.

For more information, see the Service API Help documentation that is installed with Proficy Workflow for details on how to create a custom service.

16 Proficy* Workflow

Advantages

Methods and events provided by a custom service are not restricted to use inside of workflows. They can be used by any application built with Proficy SOA. For example, custom service methods can be invoked by a form created with the Display Editor.

Custom types provided by the service are published into the SOA type catalogue. This allows objects of these types to be passed between workflows and subprocesses. It also allows them to show up correctly in the workflow debugger.

Service methods are always invoked asynchronously by workflows. This means that activities in parallel branches can continue to run while the method is invoked.

Disadvantages

Extra effort is required to write the service wrapper over the library.

Invoking a service method requires some additional communication overhead, especially if the service is running on a different machine. This communication may have a noticeable performance impact if large objects are passed between the workflow and the service.

Workflow Customization

17

Custom Workflow Activity

Another approach for exposing a .NET library to Proficy Workflow is to create one or more custom workflow activities to wrap the library. This should only be done if the library must be invoked in the same process as the workflow engine. Some reasons for this may be if the API works with large objects that would be slow to send/receive via service methods, or if it works with objects that cannot be represented by service data contracts.

For more information, see the MSDN documentation on the Windows WF 3.5 framework (the System.Workflow namespaces) for details on creating a custom activity.

Note: Proficy Workflow does not currently support activities created with the Windows WF 4.0 framework (the System.Activities namespaces).

For information on registering custom activities with Proficy Workflow, see the Third-Party Activities section in the online help.

Note: The Proficy Server service must be restarted to detect changes in the ActivityExtensions.xml file.

Advantages

Workflow activities are directly executed by the workflow engine and do not require the extra communication overhead of a service method call.

Custom activities appear directly in the activity toolbox.

Custom types that are returned by custom activities can be used by other activities by binding to properties on those objects.

18 Proficy* Workflow

Disadvantages

Writing a set of custom activities is more complex than writing a custom service.

The reusability of custom activities is limited because they can only be executed by workflows. They cannot, for example, be used by a form created with the display editor.

The workflow debugger does not support custom types that are returned from activities.

A workflow instance waits for an activity’s Execute method to complete before executing other activities in the workflow instance, even in parallel branches. Therefore, care must be taken to spend a minimal amount of time in the Execute method. Note that the currently executing activity in one workflow instance will not block the execution of other workflow instances.

Call from Code Activity

If an assembly is registered with Proficy Workflow in the ActivityExtensions.dll file, all of its contained namespaces and types will be available to the Code activity. This means that a .NET library can be directly called by the Code activity just by registering it in the ActivityExtensions.dll file, even if it does not contain any custom activities.

Advantages

This approach does not require any additional coding.

Code activities are executed asynchronously and will not block the workflow instance from running activities in parallel branches.

Workflow Customization

19

Disadvantages

If the library is exposed this way, it can only be used by workflow; it cannot be used by the Display Editor or other applications that leverage Proficy SOA.

Custom types that are returned by code activities can only use parameters of type Object. This means that other activities cannot bind to the properties of those returned objects. As such, all processing of these custom types is limited to code activities.

The workflow debugger does not debug the contents of code activities.