Introduction
This sample demonstrates how incoming events are stored in a H2 database using output RDBMS event adapter in two execution modes, which are insert and update-insert. This sample uses the default H2 database, which is shipped with WSO2 CEP.
The <CEP_HOME>/repository/conf/output-event-adapters.xml
file includes configuration details of the supported RDBMSs.
Prerequisites
Follow the steps below to set up the prerequisites before starting the configurations.
- Set up the general prerequisites that are applicable to all WSO2 CEP Samples.
Enable the following H2 database configurations by uncommenting them in the
<CEP_HOME>/repository/conf/carbon.xml
file as follows, to browse through the database and see the changes.Keep the other properties of the
H2DatabaseConfiguration
element uncommented.<H2DatabaseConfiguration> <property name="web"/> <property name="webPort">8082</property> <property name="webAllowOthers"/> </H2DatabaseConfiguration>
Starting the server
Start the WSO2 CEP server with the sample configuration numbered 0072. For instructions on starting WSO2 CEP server with a sample configuration, see Starting sample CEP configurations. This sample configuration points the default Axis2 repository to <CEP_HOME>/samples/cep/artifacts/0072/
directory.
(By default, the Axis2 repository is pointed to <CEP_HOME>/repository/deployment/server/
directory).
Executing the sample
Follow the steps below to execute the sample.
- Log in to the management console.
- Click Tools, and then click Event Simulator.
- Click Play on the corresponding event stream as shown below, to send the events in the
<CEP_HOME>/samples/cep/artifacts/0072/eventsimulatorfiles/events.csv
file to the publisher. Use the following URL to access the H2 database through your web browser: https://localhost:8082
Enter the following values to connect to the database.
Configuration Description Driver Class Enter the value as org.h2.Driver
JDBC URL Enter the URL of the database. For example: jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000 User Name wso2carbon Password wso2carbon Click Test Connection to check if the connection is successful.
- If the connection is successful, click Connect.
Output of the sample
After simulating events a new table (SENSORDATA) will be visible on the console as shown below.
The table corresponds to the following execution mode:
- SENSORDATA - Contains records of insert execution mode. Mode does not consider primary keys and keeps on inserting values as per the events.
You can observe the results of the created table as shown below.