Working with the Persister_jdbc_mysql Project

The Persister_jdbc_mysql project contains several processes that show how to use TIBCO ActiveMatrix BusinessWorks Plug-in for ActiveSpaces to persist data in a MySQL database.

The Persister_jdbc_mysql project contains the following processes:

  • Action.bwp process
  • Process.bwp process
  • Subprocesses that are called to process different persister requests

The Action.bwp process waits for the PersisterReceiver activity in the Process.bwp process to initialize, and then stores and queries tuples in the space. The process is designed with the following activities:

The following table describes the activities in this process:

Activity Description
Timer Starts the process.
Put Stores two tuples in the space.
Take Removes a tuple in the space.

The Process.bwp process receives requests from different actions of the PersisterReceiver activity and calls the corresponding subprocesses to process these requests. The process is designed with the following activities:

The following table describes the activities in this process:

Activity Description
PersisterReceiver Starts the persister and monitors the persister events. The PersisterReceiver activity includes the following action types:
  • OpenAction: this action is invoked when the persister is registered.
  • LoadAction: this action is invoked when the number of seeders that join the space reaches the value of the Minimum Seeder Count field in the Space Advanced tab.
  • ReadAction: this action is invoked when a capacity is specified for the space, and the eviction policy is set to LRU in the Space Advanced tab.
  • WriteAction: this action is invoked when a put, take, or update operation in performed in the space.
  • AlterAction: this action is invoked when the space definition is modified.
  • CloseAction: this action is invoked when the persister is stopped.
ReadActionPersisterResponse Calls the ReadAction process successfully and responds to the PersisterReceiver activity.
PersisterResponse Calls the other subprocesses successfully and responds to the PersisterReceiver activity.

The subprocesses are called based on the different actions types being used:

OpenAction.bwp Process
The OpenAction.bwp process is called when the action type for the persister event listener is OpenAction. This subprocess connects to a MySQL database. The subprocess is designed with the following activities:

The following table describes the activities in this subprocess:

Activity Description
Start Starts the process.
SQLDirect Connects to the MySQL database and executes an SQL statement to create a table named asbw.
End Ends the process.
LoadAction.bwp Process
The LoadAction.bwp process is called when the action type for the persister event listener is LoadAction. This subprocess queries all the tuples stored in the database. Additionally, this subprocess puts existing tuples in the database into the space of TIBCO ActiveSpaces. The subprocess is designed with the following activities:

The following table describes the activities in this subprocess:

Activity Description
Start Starts the process.
JDBCQuery Queries all the tuples stored in the database.
End Ends the process.
ReadAction.bwp Process
The ReadAction.bwp process is called when the action type for the persister event listener is ReadAction. This subprocess queries whether the same tuples exist in the database. The subprocess is designed with the following activities:

The following table describes the activities in this subprocess:

Activity Description
Start Starts the process.
JDBCQuery Queries whether the same tuples exist in the database.
End Ends the process.
WriteAction.bwp Process
The WriteAction.bwp process is called when the action type for the persister event listener is WriteAction. This subprocess stores, updates, and deletes the tuples in the database. The subprocess is designed with the following activities:

The following table describes the activities in this subprocess:

Activity Description
Start Starts the process.
JDBCQuery Queries whether a tuple exists in the database.
JDBC-Update Updates the tuple if the tuple being queried exists in the database.
JDBC-Insert Inserts a tuple into the database if the tuple being queried does not exist in the database.
JDBC-Delete Deletes a tuple if the tuple exists in the database.
End Ends the process.
AlterAction.bwp Process
The AlterAction.bwp process is called when the action type for the persister event listener is AlterAction. This subprocess writes a message in the persister_alter.log file. The subprocess is designed with the following activities:

The following table describes the activities in this subprocess:

Activity Description
Start Starts the process.
Write-alter Writes a message in the persister_alter.log file.
End Ends the process.
CloseAction.bwp Process
The CloseAction.bwp process is called when the action type for the persister event listener is CloseAction. This subprocess writes a message in the persister_close.log file. The subprocess is designed with the following activities:

The following table describes the activities in this subprocess:

Activity Description
Start Starts the process.
Write-Close Writes a message in the persister_close.log file.
End Ends the process.