CREATE TABLE MULE_EVENTS (
id CHAR(36) NOT NULL,
action VARCHAR(500) NULL,
application VARCHAR(500) NULL,
mule_message LONGTEXT NULL,
mule_message_id VARCHAR(36) NULL,
notification_type VARCHAR(500) NULL,
path VARCHAR(500) NULL,
resource_identifier VARCHAR(500) NULL,
timestamp BIGINT NOT NULL,
source TEXT NULL,
PRIMARY KEY (id)
);
CREATE TABLE MULE_EVENTS_ANNOTATIONS (
id CHAR(36) NOT NULL,
event_id CHAR(36) NOT NULL,
annotation_type VARCHAR(100) NULL,
annotation_value VARCHAR(255) NULL,
PRIMARY KEY (id),
KEY FK_MULE_EVENTS_ANNOTATIONS_MULE_EVENTS_IDX (event_id),
CONSTRAINT FK_MULE_EVENTS_ANNOTATIONS_MULE_EVENTS
FOREIGN KEY (event_id) REFERENCES MULE_EVENTS (id)
ON DELETE CASCADE
);
CREATE TABLE MULE_EVENTS_BUSINESS (
id CHAR(36) NOT NULL,
event_id CHAR(36) NOT NULL,
business_key VARCHAR(30) NOT NULL,
business_value VARCHAR(255) NULL,
PRIMARY KEY (id),
KEY FK_MULE_EVENTS_BUSINESS_IDX (event_id),
CONSTRAINT FK_MULE_EVENTS_BUSINESS_MULE_EVENTS
FOREIGN KEY (event_id) REFERENCES MULE_EVENTS (id)
ON DELETE CASCADE
);
Send Event Data from Runtime Manager to an External Database
You can configure the Runtime Manager agent to store the event notifications from Mule apps in a database.
Sending data to third-party software is available only for applications deployed to local servers. It is not supported for applications deployed to CloudHub.
Prerequisites
Ensure that the following software is installed:
-
Mule version 3.6 or later
-
API gateway standalone version 2.1.0 or later
-
Runtime Manager agent version 1.3.0 or later
For information about updating the agent, see Install or Update the Runtime Manager Agent.
Install Event-Tracking Database Internal Handlers
Depending on your version of the Runtime Manager agent, you might need to install the Event-Tracking Database Internal Handlers ZIP file.
For the following agent versions, you don’t need to install the ZIP file because the required JAR files are included in the agent plugin:
-
1.14.3 and later
-
2.4.5 and later
For the following agent versions, you must download and install the ZIP file manually:
-
1.14.2 and earlier
-
2.4.4 and earlier
To install the ZIP file:
-
Request the Event-Tracking Database Internal Handlers ZIP file (
mule-agent-internal-handlers-db-1.5.1.zip) from Support. -
Extract the ZIP file to the
{MULE_HOME}/plugins/mule-agent-plugin/lib/modulesfolder.
Agent Configurable Fields
After you have the latest Runtime Manager agent and the event-tracking database internal handlers installed on your API gateway, enable the internal handler by modifying your {MULE_HOME}/conf/mule-agent.yml configuration file.
In the following example configurations for MySQL Server, Oracle, and Microsoft SQL Server, the required fields are driver, jdbcUrl, user, and pass.
You can also configure the eventsTable, annotationsTable, and businessTable fields to specify where the event data is stored.
| Field | Data Type | Description | Type | Default Value |
|---|---|---|---|---|
|
String |
The JDBC driver to use to communicate with the database server |
Required |
|
|
String |
The JDBC URL for the database server |
Required |
|
|
String |
The username to use to connect to the database server |
Required |
|
|
String |
The password to connect to the database server |
Required |
|
|
String |
The name of the table in which the agent stores the events |
Optional |
|
|
String |
The name of the table in which the agent stores the annotations associated with the main event |
Optional |
|
|
String |
The name of the table in which the agent stores the custom business events associated with the main event |
Optional |
|
MySQL Example Configuration
The following example shows how to set up the Runtime Manager agent to work with MySQL databases.
Schema
Internal Handler Configuration
-
Download the MySQL JDBC driver from:
-
Extract the ZIP file.
-
Copy the
mysql-connector-java-{VERSION}.jarfile to{MULE_HOME}/plugins/mule-agent-plugin/lib/modules. -
Modify the file
{MULE_HOME}/conf/mule-agent.ymlto include the following:mule.agent.tracking.handler.database: enabled: true driver: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://192.168.61.128/mule user: root pass: test
Oracle Example Configuration
The following example shows how to set up the Runtime Manager agent to work with Oracle databases.
Schema
CREATE TABLE MULE_EVENTS (
id CHAR(36) NOT NULL,
action VARCHAR(500) NULL,
application VARCHAR(500) NULL,
mule_message CLOB NULL,
mule_message_id VARCHAR(36) NULL,
notification_type VARCHAR(500) NULL,
path VARCHAR(500) NULL,
resource_identifier VARCHAR(500) NULL,
timestamp NUMBER NOT NULL,
source CLOB NULL,
PRIMARY KEY (id)
);
CREATE TABLE MULE_EVENTS_ANNOTATIONS (
id CHAR(36) NOT NULL,
event_id CHAR(36) NOT NULL,
annotation_type VARCHAR(100) NULL,
annotation_value VARCHAR(255) NULL,
PRIMARY KEY (id),
CONSTRAINT FK_MEA_ME
FOREIGN KEY (event_id) REFERENCES MULE_EVENTS (id) ON DELETE CASCADE
);
CREATE INDEX FK_MAE_IDX ON MULE_EVENTS_ANNOTATIONS (event_id);
CREATE TABLE MULE_EVENTS_BUSINESS (
id CHAR(36) NOT NULL,
event_id CHAR(36) NOT NULL,
business_key VARCHAR(30) NOT NULL,
business_value VARCHAR(255) NULL,
PRIMARY KEY (id),
CONSTRAINT FK_MEB_ME
FOREIGN KEY (event_id) REFERENCES MULE_EVENTS (id) ON DELETE CASCADE
);
CREATE INDEX FK_MEB_IDX ON MULE_EVENTS_BUSINESS (event_id);
Internal Handler Configuration
-
Download the Oracle JDBC driver from:
-
Extract the GZ file.
-
Copy the JAR file to
{MULE_HOME}/plugins/mule-agent-plugin/lib/modules. -
Modify the file
{MULE_HOME}/conf/mule-agent.ymlto include the following:mule.agent.tracking.handler.database: enabled: true driver: oracle.jdbc.OracleDriver jdbcUrl: jdbc:oracle:thin:@192.168.61.128/XE user: root pass: test
Microsoft SQL Server Example Configuration
The following example shows how to set up the Runtime Manager agent to work with Microsoft SQL Server databases.
Schema
CREATE TABLE MULE_EVENTS (
id CHAR(36) NOT NULL,
action VARCHAR(500) NULL,
application VARCHAR(500) NULL,
mule_message VARCHAR(MAX) NULL,
mule_message_id VARCHAR(36) NULL,
notification_type VARCHAR(500) NULL,
path VARCHAR(500) NULL,
resource_identifier VARCHAR(500) NULL,
timestamp BIGINT NOT NULL,
source VARCHAR(MAX) NULL,
PRIMARY KEY (id)
);
CREATE TABLE MULE_EVENTS_ANNOTATIONS (
id CHAR(36) NOT NULL,
event_id CHAR(36) NOT NULL,
annotation_type VARCHAR(100) NULL,
annotation_value VARCHAR(255) NULL,
PRIMARY KEY (id),
CONSTRAINT FK_MULE_EVENTS_ANNOTATIONS_MULE_EVENTS
FOREIGN KEY (event_id) REFERENCES MULE_EVENTS (id)
ON DELETE CASCADE
);
CREATE INDEX FK_MULE_EVENTS_ANNOTATIONS_MULE_EVENTS_IDX ON MULE_EVENTS_ANNOTATIONS (event_id);
CREATE TABLE MULE_EVENTS_BUSINESS (
id CHAR(36) NOT NULL,
event_id CHAR(36) NOT NULL,
business_key VARCHAR(30) NOT NULL,
business_value VARCHAR(255) NULL,
PRIMARY KEY (id),
CONSTRAINT FK_MULE_EVENTS_BUSINESS_MULE_EVENTS
FOREIGN KEY (event_id) REFERENCES MULE_EVENTS (id)
ON DELETE CASCADE
);
CREATE INDEX FK_MULE_EVENTS_BUSINESS_IDX ON MULE_EVENTS_BUSINESS (event_id);
Internal Handler Configuration
-
Download the Microsoft JDBC driver for SQL Server from:
-
Extract the
sqljdbc%version%.tar.gzfile. -
Copy the appropriate
sqljdbc%version%.jarfile to{MULE_HOME}/plugins/mule-agent-plugin/lib/modules. -
Modify the file
{MULE_HOME}/conf/mule-agent.ymlto include the following:mule.agent.tracking.handler.database: enabled: true driver: com.microsoft.sqlserver.jdbc.SQLServerDriver jdbcUrl: jdbc:sqlserver://192.168.61.128:1433;databaseName=Mule; user: root pass: test



