If you configure the Gateway to log CDR to a Database, then every transaction of the Gateway is logged in the HSQLDB that comes bundled with JBoss AS and leverages the JBoss AS DataSource. However this is only made available to allow the platform to run “out of the box”. You must configure a production ready Database prior to using the Gateway in a production environment.
Mobicents USSD Gateway has been tested with PostgreSQL and MySQL. In this section, you will find instructions for configuring MySQL database for CDR logging.
Procedure A.1. Configuring MySQL as datasource for CDR logging
- Install MySQL and create a database where CDR data will be stored. In this example, a database named “test” is assumed to have been created.
- Copy the MySQL connector library (
mysql-connector-java-5.1.27-bin.jar
) from “Connector/J” in the MySQL library into library folder of the JBoss Server (mobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/lib
). - The example HSQLDB DataSource is bound to the JNDI name java:/DefaultDS and its descriptor is available in the file
mobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/deploy/hsqldb-ds.xml
. You must delete this datasource by removing this descriptor file. - Copy the descriptor file for MySQL,
mysql-ds.xml
, frommobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/docs/examples/jca/
intomobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/deploy/
. - Update the MySQL descriptor file,
mysql-ds.xml
, as required to suit your configuration. Below is an example configuration. You must update the tags <connection-url> with the host where a database can be found (‘localhost’ in this example) and the database name (‘test’ in this example). You must also update the username and password tags (‘root’ and ‘111111’ in this example).
MySqlDS jdbc:mysql://localhost:3306/test com.mysql.jdbc.Driver root 111111 org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker mySQL
- Delete the HSQLDB file for messaging persistence
mobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/deploy/messaging/hsqldb-persistence-service.xml
. - Copy the MySQL file for messaging persistence,
mysql-persistence-service.xml
, frommobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/docs/examples/jms/
intomobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/deploy/messaging
. - Update the below files to replace all “DefaultDS” values with “MySqlDS” in all occurrences in all these files.
messaging/mysql-persistence-service.xml
messaging/messaging-jboss-beans.xml
ejb2-timer-service.xml
schedule-manager-service.xml
uuid-key-generator.sar/META-INF/jboss-service.xml
- Open the file
messaging/mysql-persistence-service.xml
, go the mbean definition <mbean code=”org.jboss.messaging.core.jmx.MessagingPostOfficeService”> and locate the line <attribute name=”Clustered”>false</attribute>. Leave this attribute and comment out or remove all the lines after this till the end of this bean. Save all changes. - Open the file
mobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/deploy/mobicents-slee/META-INF/jboss-beans.xml
and locate the following bean:
<bean name="Mobicents.JAINSLEE.Profiles.JPA.PostgreSQLConfig" class="org.mobicents.slee.container.deployment.profile.jpa.Configuration"> ..... ..... </bean>
Add the following bean with properties as specified below:
<bean name="Mobicents.JAINSLEE.Profiles.JPA.MySQLDBConfig" class="org.mobicents.slee.container.deployment.profile.jpa.Configuration"> <property name="persistProfiles">true</property> <property name="clusteredProfiles">false</property> <property name="hibernateDatasource">java:/MySqlDS</property> <property name="hibernateDialect">org.hibernate.dialect.MySQLDialect</property> </bean>
- In the
jboss-beans.xml
, comment out or remove the following blocks:
<bean name="Mobicents.JAINSLEE.Profiles.JPA.HSQLDBConfig" class="org.mobicents.slee.container.deployment.profile.jpa.Configuration"> ................ </bean> <bean name="Mobicents.JAINSLEE.Profiles.JPA.PostgreSQLConfig" class="org.mobicents.slee.container.deployment.profile.jpa.Configuration"> ................ </bean>
- In the
jboss-beans.xml
, go to the Profile Management section and replace HSQLDBConfig with MySQLDBConfig as shown below.
<bean name="Mobicents.JAINSLEE.ProfileManagement"> ....replace <inject bean="Mobicents.JAINSLEE.Profiles.JPA.HSQLDBConfig" /> ....with <inject bean="Mobicents.JAINSLEE.Profiles.JPA.MySQLDBConfig" />
- You must note that
mobicents-slee-ra-jdbc-DU-6.1.1.GA-Mobicents.jar
also refers to DataSource name. You must change the value ofDATASOURCE_JNDI_NAME
(which is hardcoded in the library) in the filemobicents-ussdgateway-3.0.13/jboss-5.1.0.GA/server/<profile>/deploy/mobicents-slee-ra-jdbc-DU-6.1.1.GA-Mobicents.jar/jars/mobicents-slee-ra-jdbc-ra-6.1.1.GA-Mobicents.jar/META-INF/resource-adaptor-jar.xml
tojava:MySqlDS
. - Delete all tables from the MySql database you wish to use.
- When you run the Gateway now, you will find the
ussd_gw_cdrs
tables where all CDR will be stored.
The post USSD – Configuring MySQL as datasource appeared first on Telestax Docs Online.