The application expects database access to be provided from the Application Container via JNDI.
- Java - Oracle JDK/JRE 8 (build/runtime)
- Apache Maven - 3.5 (build)
- SQL Server - MySQL 5.7 (runtime)
- Java Servlet Container - Tomcat 8 (runtime)
The Comms Router API may work with different types of Java, SQL Server or Web Container and is currently being tested and maintained with the above component versions.
Create the database with CHARACTER SET utf8 COLLATE utf8_general_ci
.
CREATE DATABASE `comms_router_core` CHARACTER SET `utf8` COLLATE `utf8_general_ci`;
There are two options for setting up your Comms Router application database.
- Create two users Database Admin with full permissions (create, edit, delete) and Application Admin to manage Tasks, Agents, Queues and Plans.
- Create a Super Admin user to manage both database and content.
CREATE USER 'comms_router_admin'@'localhost' IDENTIFIED BY 'comms_router_admin_password';
GRANT ALL ON `comms_router_core`.* TO 'comms_router_admin'@'localhost';
CREATE USER 'comms_router'@'localhost' IDENTIFIED BY 'comms_router_password';
GRANT LOCK TABLES, SELECT, INSERT, DELETE, UPDATE ON `comms_router_core`.* TO 'comms_router'@'localhost';
CREATE USER 'comms_router'@'localhost' IDENTIFIED BY 'comms_router_password';
GRANT ALL ON `comms_router_core`.* TO 'comms_router'@'localhost';
-
First create
context.xml
configuration for Tomcat deployment either by updating:comms-router-web.xml
inCATALINA_BASE/conf/ENGINE_NAME/HOST_NAME/
or use another file.- Add a resource defined in
CATALINA_BASE/conf/context.xml
or inCATALINA_BASE/conf/ENGINE_NAME/context.xml
For more help read the Apache Tomcat 8 Configuration Reference documentation.
-
In the chosen file add the datasource resource definition with the recommended configuration.
<Resource name="jdbc/commsRouterDB" auth="Container" type="javax.sql.DataSource" username="{USERNAME}" password="{PASSWORD}" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://{HOST}:{PORT}/{DATABASE_NAME}?zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&useJDBCCompliantTimezoneShift=false&serverTimezone=UTC&useUnicode=yes&characterEncoding=UTF-8" />
Optionally it is possible to enable Database Connection Pool by setting additional options. See Database Connection Pool (DBCP 2) Configurations and BasicDataSource Configuration Parameters documentation.
<Resource name="jdbc/commsRouterDB" auth="Container" type="javax.sql.DataSource" username="{USERNAME}" password="{PASSWORD}" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://{HOST}:{PORT}/{DATABASE_NAME}?zeroDateTimeBehavior=convertToNull&useLegacyDatetimeCode=false&useJDBCCompliantTimezoneShift=false&serverTimezone=UTC&useUnicode=yes&characterEncoding=UTF-8" validationQuery="/* ping */" removeAbandonedOnBorrow="true" removeAbandonedOnMaintenance="true" removeAbandonedTimeout="60" logAbandoned="true" />
For more help read the JNDI Datasource HOW-TO.
Note: Remember to update the following parameters above for your environment
{USERNAME}
,{PASSWORD}
,{HOST}
,{PORT}
and{DATABASE_NAME}
. -
Add the Java Database Controller (JDBC) driver to the Java Virtual Machine (JVM). For Tomcat this means copying the MySQL driver
.jar
file toCATALINA_BASE/lib
.mv ~/Downloads/mysql-connector-java-5.1.XX/mysql-connector-java-5.1.XX-bin.jar CATALINA_BASE/lib
-
Comms Router uses Hibernate Java Persistence API (JPA). By default Hibernate creates tables in MySQL with the MyISAM engine which is non-transactional storage engine. Comms Router requires a transactional storage engine so a dialect is required to enable transactional storage at in the JVM running time.
Find or create
$CATALINA_BASE/bin/setenv.sh
then add dialect:export CATALINA_OPTS="$CATALINA_OPTS -Dhibernate.dialect=org.hibernate.dialect.MySQL57Dialect"
Note that MySQL5Dialect is still using the MyISAM engine, so use MySQL55Dialect or MySQL57Dialect
Find or create
%CATALINA_BASE%\bin\setenv.bat
then add dialect:set CATALINA_OPTS=%CATALINA_OPTS% -Dhibernate.dialect.storage_engine=innodb
-
Create a new
db-migrations/src/main/resources/liquibase.properties
file from thedb-migrations/src/main/resources/liquibase.properties.template
and make the following changes:verbose = true driver = com.mysql.jdbc.Driver changeLogFile = src/main/resources/db/changelog.yaml url = jdbc:mysql://localhost:3306/comms_router_core username = {USERNAME} password = {PASSWORD}
Note Username and password should be the user that has all permissions granted to access and manage database e.g.
username=comms_router
andpassword=comms_router_password
-
Populate and migrate the database to the latest version with:
cd comms-router/db-migrations/ mvn liquibase:update
Also see Manage DB Migrations for help.