Basics of Oracle Workflow

I came across the following excerpts while reading a document on Oracle Workflow and found it very useful. These writings are very basic and I will try to elaborate it further as I gain experience.

Oracle Worlflow Architecture:

Oracle Database:

The server tier is the Oracle Database that hosts the business application integrated with Oracle Workflow, the Workflow Engine, Business   Event  System, Notification System, and directory service. The Business Event System leverages the Advanced Queuing feature within the Oracle Database.

Application Server:

The application server is the middle tier environment outside the database. This environment includes ancillary service such as Oracle HTTP Server as the web server, and Oracle Workflow service components that run in the middle tier, such as agent listeners and notification mailers.

Oracle Workflow Components:

Workflow Engine-Embedded in the Oracle Database

Oracle Workflow Builder

Business Event System

Notification System

Notification Worklist

Directory Services

Status Monitor

Workflow Definitions Loader

Workflow XML Loader

Workflow Manager

A Workflow Process Definition must be saved to the same database as the Workflow Engine.You can save workflow definitions to a database or a flat file.

Oracle Advance Queuing is a feature of Oracle database that provides database integrated message queuing facility.

Oracle Workflow supports communication of JMS (Java Message Service) text messages Oracle Advanced Queuing in format called

SYS.AQ$_JMS_TEXT_MESSAGE.

Oracle workflow also supports business event messages in a standard Workflow format called WF_EVENT_T. You can additionally define  custom message formats.

Directory Services:

The directory service of oracle workflow is implemented as a set of views that are mapped across the user tables of the underlying  applications. De-normalized information is maintained in Oracle Workflow local tables for performance gains. User and role information  must be synchronized in application table by the source modules and the information in the Workflow local tables.

WF_USER

WF_ROLES

WF_USER_ROLES

WF_USER_ROLE_ASSIGNMENTS_V

Workflow Definition Loader:

The Workflow Definition Loader is a utility that lets you transfer process definitions between a database an d a flat file. It runs on the Server Machine. It is also integrated into Oracle Workflow Builder. It allows process definitions to be source controlled as flat files.

Workflow XML Loader:

It is a utility program that lets you transfer  XML definitions for Business Event System objects between a database and a flat file.

When you download Business Event System object definitions from a database , Oracle Workflow saves the definition as an XML file. When you upload object definition to a database, Oracle Workflow loads the definitions from the source XML files into the Business Event  System tables in the database, creating new definitions or updating existing definitions as necessary.

Workflow Manager:

Administrators can use the Workflow manager to perform the following tasks:

Run notification mailers and agent listeners.

Control other workflow system services , including backgroud engines , purging obsolete workflow data , and cleanup of the workflow control queue.

Service Components managed by Workflow manager-

Notification Mailers

PL/SQL agents  listeners- inbound messages on Business Event System (database)

Java Agent Listeners -inbound messages on Business Event System (Middle Tier)

Workflow Process Components:

Data Store

Item Type

Item Type Attribute

Process Activity

Event Activity

Notification Activity

Function Activity

Message

Lookup Type

Transition

Item

Process Instance

Function Activities:

All PL/SQL procedures called by function activities in a workflow process must follow the standard API format so that the workflow

engine can properly execute the activity.

procedure <procedure name > (

itemtype in varchar2,

itemkey  in carchar2,

actid  in number,

funcmode in varchar2,

resultout  out varchar2) is

<local declarations>

Begin

if funcmode=’RUN’ then

<your run executable statements>

resultout:=’COMPLETE:<result>’;

return;

endif;

—-

—-

exception

when others then

WF_CORE.CONTEXT(<package name>,<procedure name>,<item type>,<item key>,to_char(<actid>),<funcmode>);

raise;

end <procedure name>;

ItemType:The internal name of the item type

Itemkey:A string that represents a primary key generated by the workflow-enabled application.The item key uniquely identifies the item

within an item type.

actid:The ID number of the of the activity from which this prodcedure is called.

funcmode:The execution mode of the function activity(RUN,CANCEL,SKIP,RETRY)

resultout:A result that is returned depending on the result type specified for the activity.

Standard API resultout parameters:

COMPLETE

WAITING

DEFERRED:<date>     to_char(<date_string>,wf_engine.date_format)

NOTIFIED:<notification id>

ERROR:<error code>

Exception Handling:

If an activity encounters an error, information about the error is stored in the following columns in the WF_ITEM_ACTIVITY_STATUSES

table, which are viewable from the Status Monitor:

ERROR_NAME

ERROR_MESSAGE

ERROR_STACK

WF_CORE.CONTEXT adds an entry to the error stack to provide context information that helps locate the source of an error.

You can use WF_ENGINE.GetActivityAttribute(itemtype,itemkey,actid,’VALUE1′)

API to retreive the value of an activity attribute within a PL/SQL function.

Post Notification Functions:

procedure <procedure name > (

itemtype in varchar2,

itemkey  in carchar2,

actid  in number,

funcmode in varchar2,

resultout  out varchar2) is

<local declarations>

Begin

if funcmode=’RESPOND’ then

<your run executable statements>

resultout:=’COMPLETE:<result>’;

return;

endif;

—-

—-

exception

when others then

WF_CORE.CONTEXT(<package name>,<procedure name>,<item type>,<item key>,to_char(<actid>),<funcmode>);

raise;

end <procedure name>;

Post Notification Function execution modes:

VALIDATE

RESPOND

FORWARD

TRANSFER

QUESTION

ANSWER

RUN

TIMEOUT

You can refer the following global WF_ENGINE variables in your post-notification function:

WF_ENGINE.context_nid

WF_ENGINE.context_user

WF_ENGINE.context_user_comment

WF_ENGINE.context_recepient_role

WF_ENGINE.context_original_recepient

WF_ENGINE.context_from_role

WF_ENGINE.context_new_role

WF_ENGINE.context_more_info_role

WF_ENGINE.context_user_key

WF_ENGINE.context_proxy

Initiating a Workflow Process:

To initiate a workflow process your application can:

Raise an event that triggers a subscription to send the event to the process

-Call the WF_EVENT.Raise API or Java raise API or

-Execute a raise event activity in another workflow process.

Execute a procedure that calls the following workflow engine APIs:

-WF_ENGINE.CreateProcess

-WF_ENGINE.StartProcess

or

-WF_ENGINE.LaunchProcess

Activity Statuses:

After the WF Engine executes an activity ,it updates the status of the activity to one of the following statuses:

ACTIVE

COMPLETE

WAITING

NOTIFEID

DEFERRED

ERROR

SUSPEND

Calling the WF Engine:

The workflow engine must be informed when an activity completes.

Process, Notification, Function, and event activities automatically call WF_ENGINE.CompleteActivity() when they complete.

If a notification activity requires some action to be taken in a form or web page ,then that form or web page must call

WF_ENGINE.CompleteActivity() when the user completes the transaction.

If a function activity calls an external program , the you must code that external program to call WF_ENGINE.CompleteActivity() when it

completes.

Oracle Workflow APIs:

Engine APIs

Starting and running a processs

Use the following APIs to start or run a workflow process:

WF_ENGINE.CreateProcess

WF_ENGINE.StartProcess

WF_ENGINE.LaunchProcess

WF_ENGINE.SetItemOwner

WF_ENGINE.SetItemUserKey

WF_ENGINE.GetItemUserKey

WF_ENGINE.SetItemParent

WF_ENGINE.Event

WF_ENGINE.Background

WF_ENGINE.CreateForkProcess

WF_ENGINE.StartForkProcess

Communicating attribute information

WF_ENGINE.SetItemAttribute

WF_ENGINE.SetItemAttrDocument

WF_ENGINE.SetItemAttributeArray

WF_ENGINE.GetItemAttributeArray

WF_ENGINE.GetItemAttribute

WF_ENGINE.GetItemAttrDocument

WF_ENGINE.GetItemAttrClob

WF_ENGINE.GetItemAttrInfo

WF_ENGINE.AddItemAttr

WF_ENGINE.AddItemAttrArray

WF_ENGINE.GetActivityAttribute

WF_ENGINE.GetActivityAttrClob

WF_ENGINE.GetActivityAttrInfo

Communicating Stage Changes

WF_ENGINE.CompleteActivity

WF_ENGINE.CompleteActivityInternalName

WF_ENGINE.BeginActivity

WF_ENGINE.AssignActivity

WF_ENGINE.GetActivityLabel

WF_ENGINE.AbortProcess

WF_ENGINE.SuspendProcess

WF_ENGINE.ResumeProcess

WF_ENGINE.HandleError

WF_ENGINE.ItemStatus

Handling Multiple Items in bulk

WF_ENGINE_BULK.CreateProcess

WF_ENGINE_BULK.StartProcess

WF_ENGINE_BULK.FastForward

WF_ENGINE_BULK.SetItemAttrText

WF_ENGINE_BULK.SetItemAttrNumber

WF_ENGINE_BULK.SetItemAttrDate

Core APIs-Raising and catching errors

Purge APIs-Purging obsolete runtime data

Directory APIs:Communicating Directory service user and role information.

Monitor APIs

Notification APIs

Preference API

Business Event System APIs

Views

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s