Workflow Tracking Support
In This Topic
dotConnect for Oracle provides OracleTrackingParticipant class that stores TrackingRecord objects in the Oracle database. Tracking participants are the objects that allow tracking the execution of a workflow instances by subscribing for tracking records that are emitted by the workflow runtime. The tracking participants contain the logic to process the tracking records.
To store tracking records to an Oracle database, first you need to create the schema for storing tracking records. dotConnect for Oracle provides the scripts for creating this database. They are placed to the WF Services subfolder of the dotConnect for Oracle installation folder. By default it is %ProgramFiles%\Devart\dotConnect\Oracle\WF Services\. Execute the OracleTrackingSchema.sql script first and then execute OracleTrackingLogic.sql. You may use these scripts to clean up the persistence database to have a fresh database in the same way, just execute them in the same order.
Configuring InstanceStore with OracleTrackingParticipant class
To use OracleTrackingParticipant class, perform the following steps:
- Add the Devart.Data.Oracle.WorkflowFoundation assembly to References of your solution.
- Add the following line to your code: "using Devart.Data.Oracle.ActivitiesTracking".
- Create a TrackingProfile instance.
- Add tracking queries to the profile.
- Create an OracleTrackingParticipant instance, passing a connection string as the parameter to its constructor
- Assign the tracking profile to the TrackingProfile property of your OracleTrackingParticipant object.
- Add the tracking participant to Extensions of your WorkflowApplication.
TrackingProfile profile = new TrackingProfile {
Name = "SampleTrackingProfile",
ActivityDefinitionId = "*",
};
profile.Queries.Add(new WorkflowInstanceQuery { States = { "*" } });
profile.Queries.Add(new ActivityStateQuery { States = { "*" } });
profile.Queries.Add(new ActivityScheduledQuery());
profile.Queries.Add(new BookmarkResumptionQuery() { Name = "*" });
OracleTrackingParticipant trackingParticipant = new OracleTrackingParticipant("User Id=Scott;Password=tiger;Data Source=Ora;");
trackingParticipant.TrackingProfile = profile;
WorkflowApplication wfApp = new WorkflowApplication(new Workflow1());
wfApp.Extensions.Add(trackingParticipant);
wfApp.Run();
Dim profile As New TrackingProfile() With { _
Key .Name = "SampleTrackingProfile", _
Key .ActivityDefinitionId = "*" _
}
profile.Queries.Add(New WorkflowInstanceQuery() With { _
Key .States = {"*"} _
})
profile.Queries.Add(New ActivityStateQuery() With { _
Key .States = {"*"} _
})
profile.Queries.Add(New ActivityScheduledQuery())
profile.Queries.Add(New BookmarkResumptionQuery() With { _
Key .Name = "*" _
})
Dim trackingParticipant As New OracleTrackingParticipant("User Id=Scott;Password=tiger;Data Source=Ora;")
trackingParticipant.TrackingProfile = profile
Dim wfApp As New WorkflowApplication(New Workflow1())
wfApp.Extensions.Add(trackingParticipant)
wfApp.Run()
Configuring Workflow Tracking with Config File
To configure Oracle Tracking by using the oracleTracking behavior element in a configuration file, perform the following steps:
-
Add the following behavior extension element to the Machine.config file so that you can use the <oracleTracking> service behavior element in the configuration files of your applications to configure persistence for your services:
<configuration>
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="oracleTracking" type="Devart.Data.Oracle.Activities.Configuration.OracleTrackingElement, Devart.Data.Oracle.WorkflowFoundation, Version=8.4.215.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
</behaviorExtensions>
</extensions>
</system.serviceModel>
</configuration>
Note: Replace 8.4.215.0 in the code with your actual version.
-
Configure Oracle Tracking by using the oracleTracking behavior element in a configuration file of your application:
<configuration>
<system.serviceModel>
<tracking>
<profiles>
<trackingProfile name="Sample Tracking Profile">
<workflow activityDefinitionId="*">
<workflowInstanceQueries>
<workflowInstanceQuery>
<states>
<state name="Started"/>
<state name="Completed"/>
</states>
</workflowInstanceQuery>
</workflowInstanceQueries>
</workflow>
</trackingProfile>
</profiles>
</tracking>
<behaviors>
<serviceBehaviors>
<behavior name="">
<oracleTracking
connectionString="User Id=Scott;Password=tiger;Data Source=Ora;"
profileName="Sample Tracking Profile" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Configuring Workflow Tracking with OracleTrackingBehavior Class
To enable tracking using the OracleTrackingBehavior class, perform the following steps:
- Add a reference to the Devart.Data.Oracle.WorkflowFoundation.dll.
-
Add the following statement at the top of the source file after the existing "using" statements.
using Devart.Data.Oracle.Activities.Description;
Imports Devart.Data.Oracle.Activities.Description
-
Create an instance of the WorkflowServiceHost and add endpoints for the workflow service.
WorkflowServiceHost host = new WorkflowServiceHost(new CountingWorkflow(), new Uri(hostBaseAddress));
host.AddServiceEndpoint("ICountingWorkflow", new BasicHttpBinding(), "");
Dim host As New WorkflowServiceHost(New CountingWorkflow(), New Uri(hostBaseAddress))
host.AddServiceEndpoint("ICountingWorkflow", New BasicHttpBinding(), "")
-
Construct an OracleTrackingBehavior object and to set properties of the behavior object.
ServiceHost svcHost = new ServiceHost(typeof(WorkflowService), new
Uri("http://localhost:8001/Sample"));
OracleTrackingBehavior trackingBehavior = new OracleTrackingBehavior(connectionString){
ProfileName = "Sample Tracking Profile"
};
svcHost.Description.Behaviors.Add(trackingBehavior);
Dim svcHost As New ServiceHost(GetType(WorkflowService), New Uri("http://localhost:8001/Sample"))
Dim trackingBehavior As New OracleTrackingBehavior(connectionString) With { _
Key .ProfileName = "Sample Tracking Profile" _
}
svcHost.Description.Behaviors.Add(trackingBehavior)
-
Open the workflow service host.
Workflow Tracking Information
The OracleTrackingParticipant class stores the workflow tracking information in the created schema. Its tables are described below:
- wf_tracking_record - contains all tracking records.
- wf_record_type - maps numeric record type values in wf_tracking_record table to the corresponding type names.
- wf_annotation - contains annotations for tracking records.
- wf_instance_record - contains additional information for records of WorkflowInstanceRecord and derived types. This table should be joined with wf_tracking_record table to get all the WorkflowInstanceRecord data.
- wf_activity_info - contains values from ActivityInfo objects that are used in many record types.
- wf_unhandled_exception_record - contains additional information for records of WorkflowInstanceUnhandledExceptionRecord type. This table should be joined with wf_tracking_record and wf_instance_record tables.
- wf_value_collection - contains key/value collections used in tracking record (arguments and variables).
- wf_value - contains keys and values for each collection in wf_value_collection table.
- wf_activity_state_record - contains additional information for records of ActivityStateRecord type. This table should be joined with wf_tracking_record table.
- wf_activity_scheduled_record - contains additional information for records of ActivityScheduledRecord type. This table should be joined with wf_tracking_record table.
- wf_fault_propagation_record - contains additional information for records of FaultPropagationRecord type. This table should be joined with wf_tracking_record table.
- wf_cancel_requested_record - contains additional information for records of CancelRequestedRecord type. This table should be joined with wf_tracking_record table.
- wf_bookmark_resumption_record - contains additional information for records of BookmarkResumptionRecord type. This table should be joined with wf_tracking_record table.
- wf_custom_tracking_record - contains additional information for records of CustomTrackingRecord type. This table should be joined with wf_tracking_record table
Here is the diagram of this schema:
To retrieve the workflow tracking information, execute queries to these tables. For example, to retrieve all the ActivityStateRecord data for today, use the following query.
SELECT * FROM wf_tracking_record TR
INNER JOIN wf_activity_state_record SR ON TR.RECORD_ID = SR.RECORD_ID
WHERE TR.event_time >= TRUNC(SYSDATE)
See Also
Oracle Workflow Instance Store
| Development Tools and Features