Flow Persistence

Requirements

Assemble flow can be used for both short-running flow and the long-running flow. In the long-running flow, the flow engine could interact with the participate conversationally. The context information of flow instance will be passivated and reactivated for each conversation.

In previous releases, the Assemble flow engine leverage the APP zone to management the visibility and life-cycle of flow context information. The flow context could be recovered after JVM recycle, but it could not be survived after stopping zero application or JVM crashed. It could not meet the requirement for the conversational flow

Proposal

Overview

In this release, we provide a simple but extensible framework to support flow persistence. In general, the flow engine delegates the flow context management to the implementation of the FlowContextManager. FlowContextManager interface defines the basic contract between the context store and Assemble flow engine. Difference implementations of FlowContextManager support different persistence approaches, e.g. leverage GlobalContext, or database.

Registering the FlowContextManager

Assemble flow engine delegates the persistence features such as loading and saving individual instances of the flow to an interface named FlowContextManager. The implementation of FlowContextManager is configurable.

The default zero.config is as follows:

# By default, the flow context manager will use the APP zone to store the flow context
/config/assemble/flow/flowContextManager = "zero.assemble.flow.manager.impl.DefaultFlowContextManager"

There are two built-in implementations: AppZone and database, etc. The default config uses the AppZone implementation "DefaultFlowContextManager" for persisting instances in "App" zone of GlobalContext. The database implementation will persist the flow instances into the table of database.

/config/assemble/flow/flowContextManager = "zero.assemble.flow.manager.impl.JDBCFlowContextManager"

Database assess configuration

Assemble flow engine leverage "zero.data" module for the database access. The configuration of the database access is here.

You need to config your database access configuration in zero.config.

1. For the embedded Derby database

/config/db/assemble_flow_db = {
    "class" : "org.apache.derby.jdbc.EmbeddedDataSource",
    "databaseName" : "db/assemble_flow_db",
    "connectionAttributes" : "create=true"
}

2. For the network server of Derby database

/config/db/assemble_flow_db = {
    "class" : "org.apache.derby.jdbc.ClientDataSource",
    "databaseName" : "assemble_flow_db",    
    "serverName": "localhost",
    "portNumber": 1527,
    "user": "user",
    "password": "pwd"
}

3. For the MySQL database

/config/db/assemble_flow_db = {
    "class" : "com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
    "serverName" : "localhost",
    "portNumber" : 3306,
    "databaseName" : "assemble_flow",
    "user" : "user",
    "password": "pwd"
}

You can create the database with the CLI. In the project directory, you can use the following command to create the required table.

zero runsql assemble_flow_db config\sql\derby\assemble_flow_create.sql

Currently, we tested with Derby, MySQL and DB2.

The persistence policy of flow

By default, the flow instance will be persisted. But in some scenario, the flow execution is transient, it means the flow status doesn't required persistence. E.g. the feed flow to aggregate some feeds. The developer can disable the persistence to improve the performance.

The developer can use the "persistPolicy" attribute in element of flow definition to specify the persistence policy

  • on: (default): Completed instances are saved normally.
  • failed: Only failed instances are saved. The flow instance complete successfully will not be saved
  • off: No instances are saved.

E.g. disable the persistence of the feed flow

<process name="mynews" persistPolicy="off">
  <receiveGET name="rssRcv"/>
  <feed name="YahooFeed" url="http://rss.news.yahoo.com/rss/topstories"/>
  <feed name="CNNFeed" url="http://rss.cnn.com/rss/cnn_topstories.rss"/>
  <aggregateFeeds name="aggregate">
   <input value="${YahooFeed}"/>
   <input value="${CNNFeed}"/>
  </aggregateFeeds>  
  <replyGET name="rssRply">
    <input value="${aggregate}"/>
  </replyGET>
</process>

-- yili - 02 Sep 2008

r3 - 04 Sep 2008 - 06:47:49 - yili
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site