Implementing JDBC Persistent Object Store With Anypoint Clustering | MySQL Database
Clustering is group of nodes that act as a single unit. With JDBC Persistent Object Store, data can be persisted in case of Mule Runtime failure, crashes or shutdown.
Join the DZone community and get the full member experience.
Join For FreeIn this blog, we will be discussing about implementing persistent object store using MYSQL with Anypoint Clustering. We will going to see that how we can use MYSQL database to persist the object store data. One of the advantages of using persistent object store is that we will be not loosing data in case Mule Runtime or Mule Application get restarted or shutdown or crashes. In such cases, your object store data will persisted in Database.
Enabling Persistent Object Store Using MySQL With Anypoint Clustering
To enable, Persistent object store using MySQL required few steps and there are few prerequisites.
Below list of the relational databases supported
- MySQL 5.5+
- PostgreSQL 9
- Microsoft SQL Server 2014
To enable persistent object store, add below list of properties to {MULE_HOME}/.mule/mule-cluster.properties. This properties needs to be add to all nodes in the cluster.
mule.cluster.jdbcstoreurl
: JDBC Connection URL to databasemule.cluster.jdbcstoreusername
: Database usernamemule.cluster.jdbcstorepassword
: Database user passwordmule.cluster.jdbcstoredriver
: JDBC Driver class namemule.cluster.jdbcstorequerystrategy
: SQL dialect (It can be mysql, mssql, postgresql)
In our article, we will use MySQL as a Database for persistent object store and value for above properties will look like this.
mule.cluster.jdbcstoreurl=jdbc:mysql://localhost:3306/object_store
mule.cluster.jdbcstoreusername=root
mule.cluster.jdbcstorepassword=sqlserver12345
mule.cluster.jdbcstoredriver=com.mysql.cj.jdbc.Driver
mule.cluster.jdbcstorequerystrategy=mysql
In above example, I have used object_store as database. You can provide any name according to your convenience and make sure database is created before adding above properties.
Now, you need to copy driver file to {MULE_HOME}/lib/user. In my case, I have copied mysql-connector-java-8.0.26.jar file and that is MySQL driver file will be used to enable connection with MySQL database.
Once above configuration is done, you just need to restart the cluster.
The database’s tables are created automatically once you deploy application having persistent object store, as this feature creates tables for each different object store that you want to persist.
Two tables are created per object store:
- One table stores data
- Another table stores partitions.
Recommendation for Object store Database
- Create dedicated Schema or Database that can be only used by JDBC Object Store.
- Always keep in mind that the data storage needs to be hosted in a centralized DB reachable from all nodes.
- The database username configured for JDBC Object Store needs to have permission to:
- Create objects in the database (
DDL
),CREATE
andDROP
for tables. - Access and manage the objects it creates (
DML
),INSERT
,UPDATE
,DELETE
, andSELECT
.
- Create objects in the database (
Here is the step by step video tutorial explaining how to enable JDBC Persistent Object Store With Anypoint Clustering.
You can learn more about Anypoint Clustering here.
Now, you know how to implement JDBC Persistent Object Store With Anypoint Clustering.
Opinions expressed by DZone contributors are their own.
Comments