Using the BPEL Designer and Service Engine
Contents
Configuring Persistence and Recovery for the BPEL Service Engine
In order to ensure the integrity of your business process data in the case of a system failure, you can configure the BPEL Service Engine to persist business process data to a database. With BPEL Persistence enabled, the BPEL Service Engine recovers business process data that would otherwise be lost, and continues processing from the point of system failure.
Configuring the User and Database for Persistence
The BPEL Service Engine supports MySQL, Derby (JavaDB), and Oracle. This section describes how to configure the BPEL Service Engine, the user, and the database, to persist data.
Derby (JavaDB)
The BPEL Service Engine uses the JDBC resource created in the Application Server to make the necessary database connection for persistence. NetBeans is bundled with the JavaDB database, which is the Sun's supported distribution of the open source Apache Derby database. The BPEL Service Engine is configured to connect to the JavaDB database by default.
It is not necessary to create a user and database for Derby. Just create the connection pools and include the "create" flag in the database name, and set the value to "true". For example: DatabaseName → bpelseDB;create=true.
Oracle
Create the Oracle database user with required privileges and tablespace for BPEL Service Engine persistence.
- Log into Oracle as sysdba. For example, from the command prompt enter: sqlplus "sys/syspassword@tnsentry as sysdba". You need to include sqlplus in the path and the tns entry for the Oracle database.
- Execute the following script using the default values:
CREATE TABLESPACE bpelsedb DATAFILE 'bpelsedb.dat' SIZE 512M REUSE AUTOEXTEND ON NEXT 2048M MAXSIZE UNLIMITED;
CREATE USER bpelse_user IDENTIFIED BY bpelse_user DEFAULT TABLESPACE bpelsedb QUOTA UNLIMITED ON bpelsedb TEMPORARY TABLESPACE temp QUOTA 0M ON system;
GRANT CREATE session to bpelse_user;
GRANT CREATE table to bpelse_user;
GRANT CREATE procedure to bpelse_user;
GRANT select on sys.dba_pending_transactions to bpelse_user;
GRANT select on sys.pending_trans$ to bpelse_user;
GRANT select on sys.dba_2pc_pending to bpelse_user;
GRANT execute on sys.dbms_system to bpelse_user;
GRANT select on SYS.dba_2pc_neighbors to bpelse_user;
GRANT force any transaction to bpelse_user;
For more information and to download the scripts for Oracle, click here
.
Note: The user can also connect to the database from NetBeans or other SQL clients by giving the username "sys as sysdba". The password should be the same as that of the system user. You can also change the user, tablespace and datafile name, and size/quota, as per your choice and requirements.
MySQL
Create the MySQL database user with required privileges and database for BPEL Service Engine persistence.
- Log into MySQL as root. For example, from the command prompt enter: mysql -h host -u root -p. You need to include the MySQL bin folder in the path. You can omit the host if you are connecting from the same machine.
- Execute the following script using the default values:
CREATE DATABASE BPELSE_USER_DB;
GRANT ALL ON BPELSE_USER_DB.* TO 'BPELSE_USER'@'%' IDENTIFIED BY 'BPELSE_USER';
For more information and to download the scripts for MySQL, click here
.
Setting max_allowed_packet
When a MySQL client or the mysqld server gets a packet that is larger than the max_allowed_packet bytes, it issues a "Packet too large" error and closes the connection. By default this value is configured low. You must increase this value for large messages. Set the value of this parameter to the size of the biggest message you anticipate.
To set max_allowed_packet:
- Open the "my.ini" file under the MySQL server install directory.
- Search for the "max_allowed_packet" parameter. If the file does not have it, add the parameter to the file.
- Set the value as needed. To set the value to 1GB, enter the value as one of the following:
max_allowed_packet=1073741824
max_allowed_packet=1G
- Restart the MySQL Server.
For more information see Setting max_allowed_packet
and Using Options to Set Program Variables
.
IMPORTANT: The current version of the JDBC driver for MySQL, MySQL Connector/J, version 5.1.6, has a bug which can cause errors when an XA connection is used. As such, using this driver can cause fatal exceptions in the BPEL Service Engine. A patch for MySQL Connector/J version 5.1.6
, is available, and will be included in subsequent releases of MySQL Connector/J. For more information on the patch, see http://bugs.mysql.com/bug.php?id=35489
Setting the GlassFish JVM Classpath to the Database Drivers
The database JDBC drivers must be either set in the GlassFish JVM classpath (preferred), or placed in the local /glassfish/lib directory, before you create the connection pools. This is not necessary for the Derby (JavaDB) database, but is required for Oracle or MySQL. For example, if you are using JDK 6, your GlassFish JVM classpath must be set to the ojdbc6.jar file, which is the Oracle database JDBC driver for JVM6.
To set the GlassFish JVM Classpath Settings:
- Open the GlassFish Admin Console. To access the Admin Console do the following:
- From the Services window of the NetBeans IDE, start the GlassFish server.
- Right-click the GlassFish server and select View Admin Console from the popup menu.
- Login to the Admin Console. The default username is admin, and password is adminadmin.
- To access the GlassFish JVM classpath settings, do the following:
- From the Common Tasks window, click Application Server.
- From the Application Server window, click the JVM Settings tab and Path Settings sub-tab.
- In the Classpath Suffix field, type the full path for your database JDBC driver on your local directory. For example C:\GlassFishESB\drivers\oracle11gDriver\ojdbc6.jar.
- Click Save, and restart GlassFish.
Adding the Database Drivers in a Clustered Environment
Additional steps must be taken to add the JDBC database drivers in a clustered environment. For more information see Configuring the BPEL Service Engine for Clustering.
Creating an XA Connection Pool and a JDBC Resource
Note: Before you create Connection Pools, you must first set the GlassFish JVM classpath for your database JDBC drivers. See Setting the JVM Classpath to the Database Drivers above for more information.
To create an XA Connection Pool:
- Log into the GlassFish Admin Console.
To do this, right-click your application server node, in the Services window under Servers, and choose View Admin Console. You can also open the Admin Console from your web browser using the correct URL. For example: http://localhost:4848.
The default log in is username:admin, password: adminadmin
- In the navigation tree, expand the following nodes: Resources → JDBC.
- Select Connection Pools, and in the right panel, click the New button.
- Under General Settings, specify a name (such as bpelseDB).
- Set the Resource Type to javax.sql.XADataSource.
- Set the database vendor to the appropriate database vendor (Derby, Oracle or MySQL). Click next.
- From the New JDBC Connection Pool (Step 2 of 2) window, under Connection Validation, enable Allow Non Component Callers.
- Under Additional Properties, specify the following properties for your database:
(If you did not use the default values, make sure that the ServerName, User, Password and DatabaseName are those that you specified when you created the database.)
- Derby:
- ServerName: machine-name
- DatabaseName: DatabaseName: bpelseDB;create=true
- User: bpelse_user
- Password: bpelse_user
- Oracle:
- URL → jdbc:oracle:thin:@machine-name:port:sid
- User → bpelse_user
- Password → bpelse_user
- MySQL:
- URL → jdbc:mysql://machine-name:port/databasename
- User → bpelse_user
- Password → bpelse_user
- Click Finish. The new user and database are created.
- Click the connection pool name and click the Ping button to verify your database connection.
- Click Finish.
To create a new JDBC resource:
- From the admin console navigation tree, expand the Resources → JDBC nodes, and select JDBC Resources.
- In the right panel, click the New button.
- Provide a JNDIName (such as jdbc/bpelseDB) and specify the JDBC Connection Pool (bplseDB) you created previously.
You will use this JNDIName later when you enable persistence in the BPEL Service Engine properties.
- Expand the Configuration node and select Transaction Service (or Configurations → server-config → Transaction Service, if clustering is configured).
- For the On Restart parameter, enable Automatic Recovery by selecting the Enabled check box.
Creating a Non-XA Connection Pool and a JDBC Resource
To create a non-XA Connection Pool, follow the same procedure as you would to create an XA Connection Pool and JDBC Resource, but substitute javax.sql.ConnectionPoolDataSource as the Resource Type.
Enabling Persistence for the BPEL Service Engine
Persistence is configured in the BPEL Service Engine runtime properties.
To enable persistence for the BPEL Service Engine:
- In the NetBeans IDE Services window, expand the Sun Java System Application Server (GlassFish) → JBI → Service Engines Nodes.
- Right-click sun-bpel-engine and select Properties.
The sun-bpel-engine Properties window appears.
- Set the Persistence Enabled property value to true.
- Set the Non XA Data Source Name property to specify the JNDIName of the non-XA JDBC resource that you created when you configured the database.
- Set the XA Data Source Name property to specify the JNDIName of the XA JDBC resource that you created when you configured the database.
- Click Close to save your settings.
- Stop, shut down, and start the BPEL Service Engine to enable your new settings.
Truncating and Dropping Tables
The following notes provide drop and truncate scripts as well as additional information about configuring persistence. Some of the instructions mentioned here may change, so check back for updates or contact the BPEL Service Engine team if you have questions.
When the BPEL Service Engine is started, it queries the database for the existence of the tables required for persistence. If these tables are not available, the BPEL Service Engine will create the required tables.
Drop and Truncate Scripts
To download the scripts, click Drop and Truncating Table Scripts
. You can also refer to How to Delete From UI
for more information.
For the script to drop an Oracle user
, use the following:
DROP TABLESPACE BPELSE_USER_DB INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;
Previous
Next