mysql -u root -D mysql -p
Persisting MMC Data to MySQL
This document will cover how to persist environment and transaction data to MySQL databases. Follow the instructions to MySQL Installation, then follow the specific instructions for Persisting Environment Data or Persisting Transaction Data persistence to set up your user, create your database, and configure your MMC instance to persist your data.
Remember that environment data and transaction data must exist in two separate databases (regardless of whether they are on the same server or use the same platform). |
Jump to:
Assumptions
This document assumes that you have an understanding of the data persistence options for environment and transaction data and that you are familiar with the basic Architecture of the Mule Management Console. It also assumes that you have installed:
-
Mule Enterprise 3.4.1. Download it from the customer portal if you need to upgrade to this version.
-
MMC Version 3.4.1. Download it from the customer portal if you need to upgrade to this version.
-
a Web application server such as Tcat, Tomcat, or JBoss. Please refer to the Hardware and Software Requirements for the latest information about hardware requirements and supported application servers, Java Runtime Environments, and browsers.
For practical purposes, this document mentions Tomcat as the servlet container; however, the instructions contained here apply also to Tcat or JBoss. If you are using Tcat or JBoss, make sure to unpack the Management Console .war file in the appropriate directory. For additional information, see Installing the Production Version of MMC.
In this document, <MMC_HOME> refers to the directory where MMC is installed. If using the trial version, this is <Mule install path>/mmc/webapps/mmc , for example /opt/mule/mule-enterprise-3.4.1/mmc/webapps/mmc . If using an application server such as Tomcat, this should be similar to <Tomcat root>/webapps/mmc-console-3.4.1 , for example /var/lib/tomcat6/webapps/mmc-console-3.4.1 .
|
MySQL Installation
The MySQL installation outlined here is basic: the database is installed on the local machine on the default port of 3306, with security deactivated (using an unsecured connection to the database, and a user with full admin rights).
Tools
This configuration was tested with MySQL Community Server 5.5.
Creating a database and database user in MySQL is relatively simple. You can perform these tasks either with the mysql
command-line utility, or with the phpMyAdmin
Web-based administration tool. This document does not describe how to set up or install MySQL, or how to create the tables with phpMyAdmin
; however, it does list the commands to create the database, user, and tables for the environment data persistence example below. See the expandable section in Creating the Tables for details.
Persisting Environment Data
To set up MySQL to persist your MMC environment data, you need to complete these steps:
-
Create the database.
-
Create the database user.
-
Create the tables.
-
Set up MMC.
-
If your MySQL is on a remote host, perform some additional configuration.
The embedded database files for the Mule console reside at one of the following directories:
After you configure MMC to use an external database to store its persistent data, do not delete the |
Creating the Database
Create a new database with the following parameters:
-
Database name:
mmc_persistency_status
-
Database owner:
MMC_STATUS
Creating the Database User
Create a new database user with default permissions and the following parameters:
-
Username:
MMC_STATUS
-
Password:
mmc123
Creating the Tables
Navigate to the following directory: <MMC_HOME>/WEB-INF/classes/quartz
. In this directory you will find two scripts for MySQL:
-
tables_mysql.sql
for MySQL server versions earlier than 4.1 -
tables_mysql_version_4_1_and_above.sql
for MySQL server versions 4.1 and above
Depending on your MySQL server version, execute the appropriate script in the target database, mmc_persistency_status
.
Creating the database, user and tables with the mysql utility
The example below includes the command output for table
At this point, you’ve finished configuring MySQL. You can proceed to set up the Management Console to use the database you’ve just created. |
Setting Up MMC to use MySQL for Persisting Environment Data
-
First, install the appropriate Obtaining MySQL Drivers.
-
Then, follow the instructions below for editing the following configuration files:
This example uses the parameters employed Persisting Environment Data when creating the MySQL database.
-
MySQL listening host and port: localhost port 3306
-
Database name:
mmc_persistency_status
-
Database user:
MMC_STATUS
-
Password:
mmc123
Obtaining MySQL Drivers
-
Download the latest MySQL driver. (You need a free Oracle account to download.) The driver is called
mysql-connector-java-<version>
, such asmysql-connector-java-5.1.26
. You can download the driver as a zip or tar.gz file. -
Extract the .zip or .tar.gz installation file. In the resulting directory structure, locate the file called
mysql-connector-java-<version>-bin.jar
. This is the jbdc driver itself, that you will copy to the Management Console directory structure.
Configuration file: mmc.properties
(Directory: <MMC_HOME>/WEB-INF/classes/META-INF.)
-
In the directory listed above, locate the file
mmc.properties
. -
Open the file for editing, then edit it as per the following. ++
datasource.driver=com.mysql.jdbc.Driver
datasource.username=MMC_STATUS
datasource.password=mmc123
datasource.url=jdbc:mysql://localhost/mmc_persistency_status
script=mysql
mmc.data=./mmc-data
plugin.directory=WEB-INF/plugins
console.inactivityTimeout=60
In the above example and in all configuration files in this section, the database URL assumes the default port for MySQL server, 3306. If your MySQL server is listening on a different port, include the port number in the URL, with the following format: jdbc:mysql://<host>:<port>/<database name> .
|
Make sure that the following line does not appear:
This line would conflict with the parameters for accessing the correct database, resulting in a connection error. If the line is present in the |
Configuration file: applicationContext.xml
(Directory: Same as previous file (<MMC_HOME>/WEB-INF/classes/META-INF).)
-
In the directory listed above, locate the file named
applicationContext.xml
and open it for editing. -
Look for the bean named
internalDataSource
, then edit it as per the following.
<bean name="internalDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<!-- TODO: change this via the configurator -->
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<property name="username" value="MMC_STATUS"/>
<property name="password" value="mmc123"/>
</bean>
Configuration file: jackrabbit-repo.xml
Before editing this file, delete the following files (if listed):
|
(Directory: Same as previous file (<MMC_HOME>/WEB-INF/classes/META-INF).)
-
In the directory listed above, locate the file
jackrabbit-repo.xml
and open it for editing. -
Replace the appropriate parameters to use MySQL instead of the default Derby database. Use the following parameters for the database connection:
-
User:
MMC_STATUS
-
Password:
mmc123
-
URL:
jdbc:mysql://localhost/mmc_persistency_status
-
Schema:
mysql
-
Driver:
com.mysql.jdbc.Driver
-
IP:
localhost
-
Port:
3306
(default at installation)
-
-
Replace the parameters in the appropriate sections, which are displayed in the code snippets below.
The schema should be always mysql . It defines the database, not the actual schema to be used for storing persistent data.
|
...
<Repository>
<!--
virtual file system where the repository stores global state
(e.g. registered namespaces, custom node types, etc.)
-->
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
...
...
<!--
workspace configuration template:
used to create the initial workspace if there's no workspace yet
-->
<Workspace name="Jackrabbit Core">
<!--
virtual file system of the workspace:
class: FQN of class implementing the FileSystem interface
-->
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
...
When configuring the default workspace and the workspace name itself, ensure that you comply with one of the following conditions:
If neither of the above conditions are met, all binary data persists locally instead of on the external database. |
...
<!--
persistence manager of the workspace:
class: FQN of class implementing the PersistenceManager interface
-->
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
<param name="schemaObjectPrefix" value="Jackrabbit Core_"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="externalBLOBs" value="true"/>
<param name="schemaCheckEnabled" value="true"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</PersistenceManager>
...
PersistenceManager parameters The The |
...
<!--
Search index and the file system it uses.
class: FQN of class implementing the QueryHandler interface
-->
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index"/>
<param name="textFilterClasses"
value="org.apache.jackrabbit.extractor.PlainTextExtractor,
org.apache.jackrabbit.extractor.MsExcelTextExtractor,
org.apache.jackrabbit.extractor.MsPowerPointTextExtractor,
org.apache.jackrabbit.extractor.MsWordTextExtractor,
org.apache.jackrabbit.extractor.PdfTextExtractor,
org.apache.jackrabbit.extractor.HTMLTextExtractor,
org.apache.jackrabbit.extractor.XMLTextExtractor,
org.apache.jackrabbit.extractor.RTFTextExtractor,
org.apache.jackrabbit.extractor.OpenOfficeTextExtractor" />
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
</SearchIndex>
...
...
<Versioning rootPath="${rep.home}/version">
<!--
Configures the filesystem to use for versioning for the respective
persistence manager
-->
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
...
...
<!--
Configures the persistence manager to be used for persisting version state.
Please note that the current versioning implementation is based on
a 'normal' persistence manager, but this could change in future
implementations.
-->
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
<param name="schemaCheckEnabled" value="true"/>
<param name="schemaObjectPrefix" value="version_"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="externalBLOBs" value="true"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</PersistenceManager>
</Versioning>
...
...
<!--
Search index for content that is shared repository wide
(/jcr:system tree, contains mainly versions)
-->
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${rep.home}/repository/index"/>
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
</SearchIndex>
</Repository>
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.2//EN"
"http://jackrabbit.apache.org/dtd/repository-1.2.dtd">
<Repository>
<!--
virtual file system where the repository stores global state
(e.g. registered namespaces, custom node types, etc.)
-->
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
<!--
security configuration
-->
<Security appName="Jackrabbit">
<!--
access manager:
class: FQN of class implementing the AccessManager interface
-->
<AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
<!-- <param name="config" value="${rep.home}/access.xml"/> -->
</AccessManager>
<LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
<!-- anonymous user name ('anonymous' is the default value) -->
<param name="anonymousId" value="anonymous"/>
<!--
default user name to be used instead of the anonymous user
when no login credentials are provided (unset by default)
-->
<!-- <param name="defaultUserId" value="superuser"/> -->
</LoginModule>
</Security>
<!--
location of workspaces root directory and name of default workspace
-->
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
<!--
workspace configuration template:
used to create the initial workspace if there's no workspace yet
-->
<Workspace name="Jackrabbit Core">
<!--
virtual file system of the workspace:
class: FQN of class implementing the FileSystem interface
-->
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
<!--
persistence manager of the workspace:
class: FQN of class implementing the PersistenceManager interface
-->
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
<param name="schemaObjectPrefix" value="Jackrabbit Core_"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="externalBLOBs" value="true"/>
<param name="schemaCheckEnabled" value="true"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</PersistenceManager>
<!--
Search index and the file system it uses.
class: FQN of class implementing the QueryHandler interface
-->
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${wsp.home}/index"/>
<param name="textFilterClasses"
value="org.apache.jackrabbit.extractor.PlainTextExtractor,
org.apache.jackrabbit.extractor.MsExcelTextExtractor,
org.apache.jackrabbit.extractor.MsPowerPointTextExtractor,
org.apache.jackrabbit.extractor.MsWordTextExtractor,
org.apache.jackrabbit.extractor.PdfTextExtractor,
org.apache.jackrabbit.extractor.HTMLTextExtractor,
org.apache.jackrabbit.extractor.XMLTextExtractor,
org.apache.jackrabbit.extractor.RTFTextExtractor,
org.apache.jackrabbit.extractor.OpenOfficeTextExtractor" />
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
</SearchIndex>
</Workspace>
<!--
Configures the versioning
-->
<Versioning rootPath="${rep.home}/version">
<!--
Configures the filesystem to use for versioning for the respective
persistence manager
-->
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
<!--
Configures the persistence manager to be used for persisting version state.
Please note that the current versioning implementation is based on
a 'normal' persistence manager, but this could change in future
implementations.
-->
<PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.MySqlPersistenceManager">
<param name="schemaCheckEnabled" value="true"/>
<param name="schemaObjectPrefix" value="version_"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="externalBLOBs" value="true"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</PersistenceManager>
</Versioning>
<!--
Search index for content that is shared repository wide
(/jcr:system tree, contains mainly versions)
-->
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
<param name="path" value="${rep.home}/repository/index"/>
<FileSystem class="org.apache.jackrabbit.core.fs.db.DbFileSystem">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="url" value="jdbc:mysql://localhost/mmc_persistency_status"/>
<param name="schema" value="mysql"/>
<param name="schemaObjectPrefix" value="rep_"/>
<param name="user" value="MMC_STATUS"/>
<param name="password" value="mmc123"/>
</FileSystem>
</SearchIndex>
</Repository>
Configuration file: scheduler.properties
(Directory: Same as previous files (`<MMC_HOME>/`WEB-INF/classes/META-INF).)
-
In the directory listed above, locate the file called
scheduler.properties
, then open it for editing. -
Edit the file as per the following.
org.quartz.jobStore.isClustered=false org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.jobStore.useProperties=true org.quartz.scheduler.instanceId=AUTO
-
The Management Console is now configured to store its persistent data in the specified MySQL database. Start the Management Console and login normally.
Connecting to a Remote MySQL Server
If the MySQL server resides on a remote host, you are most likely unable to connect, unless you perform the following two actions:
-
configure the MySQL server to allow remote database connections
-
grant privileges to your database user allowing it to connect remotely
Both actions are described in the following two sections.
Remote Database Connections
-
To check that the MySQL server allows remote database connections, locate the MySQL server configuration file, for example
/etc/mysql/my.cnf
. -
Search for the following line.
bind-address = 127.0.0.1
-
If the line exists, perform the following steps:
-
Stop the MySQL server.
-
Open the configuration file for editing, then comment out the line with a number sign (#), as shown below.
# bind-address = 127.0.0.1
-
Close the file, then restart the MySQL server.
-
Remote Access Privileges
-
To grant remote database access to your database user, login to MySQL as the MySQL server root user, using the following command.
mysql -u root -D mysql -p
-
Enter the password for root.
-
Obtain the 41-digit hexadecimal representation of the database user’s password (in this case, the password for user MMC_STATUS) by running the following command.
SELECT * FROM user WHERE User = '<user>';
-
In the output from the previous command, find, then copy the 41-digit hex number, which is preceded by an asterisk. Ensure that you save this number to your clipboard or a text file, since you will use it in the next step. A snippet of example output is shown below.
mysql> SELECT * FROM user WHERE User = 'MMC_STATUS'; +--------------+------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+ | Host | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string | +--------------+------------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+ | localhost | MMC_STATUS | *14695FC49478AC013A63030250DD44DE579D54E1 | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N |
-
Grant the privileges with the following command. For the
<password>
parameter, paste the 41-digit hex number you copied in the previous step.GRANT ALL PRIVILEGES ON <database>.* TO '<user>'@'<host|net>' IDENTIFIED BY PASSWORD '<password>' WITH GRANT OPTION;
-
Tell the MySQL server to reload the grant tables, with the following command.
FLUSH PRIVILEGES;
Details and usage example for the GRANT ALL PRIVILEGES command The value of The value of
A complete command example follows.
|
Testing the remote connection with the telnet command If you are unsure of the MySQL server configuration, but are certain that you have connectivity to the MySQL server host and port (i.e. you are sure there are no routing issues, firewalls, etc. blocking connectivity), then you can use the If the MySQL server is not accepting remote connections, trying to telnet to the MySQL host and port results in a "Connection refused error," even if the server is indeed listening on the specified host and port.
If the MySQL server is accepting remote connections, but there is no user allowed to connect remotely, the output appears similar to the following. In this example, the connection succeeds but is closed by the remote host.
If connectivity to the MySQL server is fully working, and the server is granting user access, the output appears similar to the following.
If you obtain this output, but cannot successfully connect the Management Console to the remote MySQL server, then something is likely wrong with the Management Console configuration. Check the logs in Mule or your Web app server for details. |
Persisting Transaction Data
To set up MySQL to persist your MMC transaction data, you need to complete these steps:
-
Create the database.
-
Create the database user.
-
Set up MMC.
Creating the Database
Create a new database with the following parameters:
-
Database name:
event_tracker
-
Database owner:
MMC_EVENTS
Creating the Database User
Create a new database user with default permissions and the following parameters:
-
Username:
MMC_EVENTS
-
Password:
mmc123
Setting Up MMC to use MySQL for Persisting Transaction Data
Obtaining MySQL Drivers
-
Download the latest MySQL driver. (You need a free Oracle account to download.) The driver is called
mysql-connector-java-<version>
, such asmysql-connector-java-5.1.26
. You can download the driver as a zip or tar.gz file. -
Extract the zip or tar.gz installation file. In the resulting directory structure, locate the file called
mysql-connector-java-<version>-bin.jar
. This is the jbdc driver itself, that you will copy to the Management Console directory structure.
Database-Specific Configuration
Configuration File: persistence.xml
(Directory: <MMC_HOME>/`WEB-INF/classes/META-INF.)
-
In the directory listed above, locate the file
persistence.xml
. -
Open the file for editing, then find the line listed below.
<property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.H2Dictionary(batchLimit=-1)" />
-
Edit the line as per below.
<property name="openjpa.jdbc.DBDictionary" value="mysql" />
Configuration File: applicationContext-tracking.xml
(Directory: Same as previous file (<MMC_HOME>/`WEB-INF/classes/META-INF).)
-
In the directory listed above, locate the file
applicationContext-tracking.xml
. -
Open the file for editing.
-
Find the beans
dataSource
andjpaAdapter
as per the listing below.
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://<db_host>:3306/event_tracker" />
<property name="username" value="MMC_EVENTS" />
<property name="password" value="mmc123" />
</bean>
[...]
<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
<property name="databasePlatform" value="mysql" />
</bean>
Modifying the Cleanup Script For MySQL
MMC includes a script to perform a routine cleanup of the MMC database, which by default takes place every day at midnight. The current script for MySQL contains a bug which causes MySQL to throw an SQL exception. To avoid this issue, replace the original script with the one provided below, by completing the following steps.
New Cleanup Script
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import com.mulesoft.mmc.tracking.repository.jpa.entities.*
import java.util.Calendar;
def logger = log
def oneWeekAgo = Calendar.getInstance()
oneWeekAgo.add(Calendar.DAY_OF_MONTH, -7);
log.info("About to delete all tracking details older than "+oneWeekAgo.getTime());
DriverManagerDataSource ds = applicationContext.getBean("dataSource");
Properties properties = new Properties();
properties.put("openjpa.jdbc.DBDictionary", "mysql");
properties.put("javax.persistence.jdbc.url", ds.getUrl());
properties.put("javax.persistence.jdbc.user", ds.getUsername());
properties.put("javax.persistence.jdbc.password", ds.getPassword());
properties.put("openjpa.ConnectionDriverName", "com.mysql.jdbc.Driver");
EntityManagerFactory emf = null;
EntityManager em = null;
try {
emf = Persistence.createEntityManagerFactory("tracking-persistence-unit", properties);
em = emf.createEntityManager();
em.getTransaction().begin();
em.createNativeQuery("DELETE p FROM EVENT_PROPERTIES p where p.id in (select e.id from EVENTS e where e.transaction_id in (select t.id from TRANSACTION_SUMMARIES t where t.timestamp < ?1))").setParameter(1, oneWeekAgo).executeUpdate();
em.createNamedQuery(EventEntity.DELETE_OLDER_THAN_QUERY_NAME).setParameter("timestamp", oneWeekAgo).executeUpdate();
em.createNamedQuery(TransactionSummaryEntity.DELETE_OLDER_THAN_QUERY_NAME).setParameter("timestamp", oneWeekAgo).executeUpdate();
em.getTransaction().commit();
} catch (RuntimeException re)
{
if (em?.getTransaction()?.isActive()) {
em.getTransaction().rollback();
}
throw re;
}
finally {
em?.close();
emf?.close();
}
Replacing the Old Script
-
Log in to MMC.
-
Go to the Administration tab, then Admin Shell. You should see the following screen.
-
Click Cleanup Tracking DB in the column to the right. This displays the contents of the script in the editor box, as shown below.
-
Now you can edit the script as desired. Delete all of the contents of the script, leaving the editor blank.
-
Copy-paste the New Cleanup Script into the editor.
-
Click Save. This causes the new script to overwrite the old one.
See Also
-
Read more about MMC setup.
-
Review the Architecture of the Mule Management Console.