Nav

Sending Event Data from Runtime Manager to External Data Bases

logo cloud disabled logo hybrid active logo server active logo pcf disabled

By simply configuring a few settings, the event notifications produced by your running Mule Applications can be easily stored in a database.

Sending data to third party software is a feature that is currently only available for applications deployed to local servers. It is not available for applications that you deploy via the Runtime Manager to CloudHub. See Deployment StrategiesDeployment Strategies.

It’s not available either for applications deployed to Pivotal Cloud Foundry (PCF).

Prerequisites

Please make sure you have the following software installed:

  • Mule ESB – Version 3.6 or above

  • API Gateway Standalone – Version 2.1.0 or above (optional in case you want to deal with apps that are built with the API Gateway Runtime)

  • The Runtime Manager Agent Plugin version 1.3.0 or above

Install the Runtime Manager Agent

First you must install the Runtime Manager Agent, which is in charge of sending messages out of mule. In order to send event information to third party software, you need to have version 1.3.0 or newer of the Runtime Manager Agent.

Install Event Tracking Database Internal Handlers

Download the API Analytics Tracking Database Internal Handlers from here and unzip them on {MULE_HOME}/plugins/mule-agent-plugin/lib/modules folder.

Agent Configurable Fields

Once you have the latest Runtime Manager Agent and the Event Tracking Database Internal Handlers installed on your API Gateway Standalone server you enable the internal handler by modifying your {MULE_HOME}/conf/mule-agent.yml configuration file.

Below we provide example configurations for MySQL Server, ORACLE and Microsoft SQL Server.

Although the required fields are driver, jdbcUrl, user and pass. You can also configure the eventsTable, annotationsTable and businessTable in which the events data is stored.

Field Data Type Description Type Default Value

driver

String

Represents the JDBC driver to use to communicate with the database server.

Required

jdbcUrl

String

Represents the JDBC url to the database server.

Required

user

String

The username to connect to the database server.

Required

pass

String

The password to connect to the database server.

Required

eventsTable

String

Represents the name of the table in which the agent will store the events.

Optional

MULE_EVENTS

annotationsTable

String

Represents the name of the table in which the agent will store the annotations associated to the main event.

Optional

MULE_EVENTS_ANNOTATIONS

businessTable

String

Represents the name of the table in which the agent will store the custom business events associated to the main event.

Optional

MULE_EVENTS_BUSINESS

Proposed Configurations

Below are a few examples for setting up the agent for working with some of the most common databases.

MySQL

Schema


           
        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
);

Internal Handler Configuration

  1. Download the MySQL JDBC driver from http://dev.mysql.com/downloads/connector/j/.

  2. Extract the .zip file to obtain the mysql-connector-java-VERSION-bin.jar file

  3. Copy this .jar file to {MULE_HOME}/plugins/mule-agent-plugin/lib/modules.

  4. Modify the file {MULE_HOME}/conf/mule-agent.yml to include the following:

    
                  
               
    1
    2
    3
    4
    5
    6
    7
    
    ---
      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

Schema


           
        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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

  1. Download the Oracle JDBC driver from http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html.

  2. Extract the .zip file to obtain the .jar file

  3. Copy this .jar file to {MULE_HOME}/plugins/mule-agent-plugin/lib/modules.

  4. Modify the file {MULE_HOME}/conf/mule-agent.yml to include the following:

    
                  
               
    1
    2
    3
    4
    5
    6
    7
    
    ---
      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

Schema


           
        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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

  1. Download the Microsoft JDBC driver from https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774.

  2. Extract the sqljdbc_4_%version%.tar.gz file to obtain the sqljdbc4%version%_.jar file

  3. Copy this .jar file to {MULE_HOME}/plugins/mule-agent-plugin/lib/modules.

  4. Modify the file {MULE_HOME}/conf/mule-agent.yml to include the following:

    
                  
               
    1
    2
    3
    4
    5
    6
    7
    
    ---
      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

See Also