Powered By Blogger

May 14, 2014

Create a JDBC mount to WSO2 Governance Registry


This blog post basically describes about the way to do a JDBC mount by using WSO2 Governance Registry (GReg) and WSO2 Enterprise Service Bus (ESB)

Applies To : WSO2 Governance Registry 4.6.0

                      WSO2 Enterprise Service Bus 4.8.1

Configure Governance Registry

  • Create a new database for Governance Registry (eg: GregDB)
  • Then update the datasource configuration in master-datasource.xml in $GREG_HOME/repository/conf/datasources
  • Update the url, username, password and driverClassName of the datasource configuration

<datasource>

           <name>WSO2_CARBON_DB</name>

           <description>The datasource used for registry and user manager</description>

           <jndiConfig>
               <name>jdbc/WSO2CarbonDB</name>
           </jndiConfig>
           <definition type="RDBMS">
               <configuration>
                   <url>jdbc:mysql://localhost:3306/GregDB</url>
                   <username>root</username>
                   <password>root</password>
                   <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                   <maxActive>50</maxActive>
                   <maxWait>60000</maxWait>
                   <testOnBorrow>true</testOnBorrow>
                   <validationQuery>SELECT 1</validationQuery>
                   <validationInterval>30000</validationInterval>
               </configuration>
           </definition>
 </datasource>

  • Enabling clustering in axis2.xml in $GREG_HOME/repository/conf/axis2 to send invalidation messages across WSO2 GREG and WSO2 ESB.
<clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="true"/>

  • Copy the MySql driver library (mysql-connector-java-5.1.13-bin.jar) to $GREG_HOME/repository/components/lib directory.
Configure WSO2 Enterprise Service Bus
  • Enable database access by copying the MySQL driver library (mysql-connector-java-5.1.13-bin.jar) to $ESB_HOME/repository.components/lib.
  • Add a new datasource configuration to master-datasources.xml in $ESB_HOME/repository/conf/datasources

<datasource>

           <name>WSO2_CARBON_DB_GREG</name>

           <description>The datasource used for registry and user manager</description>

           <jndiConfig>
               <name>jdbc/WSO2CarbonDB_GREG</name>
           </jndiConfig>
           <definition type="RDBMS">
               <configuration>
                   <url>jdbc:mysql://localhost:3306/GregDB</url>
                   <username>root</username>
                   <password>root</password>
                   <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                   <maxActive>50</maxActive>
                   <maxWait>60000</maxWait>
                   <testOnBorrow>true</testOnBorrow>
                   <validationQuery>SELECT 1</validationQuery>
                   <validationInterval>30000</validationInterval>
               </configuration>
           </definition>
       </datasource>

  • Add new db config to registry.xml in $ESB_HOME/repository/conf in order to refer the newly added data source.

<dbConfig name="mounted_registry">

       <dataSource>jdbc/WSO2CarbonDB_GREG</dataSource>
</dbConfig>



  • Add a remote governance registry instance in registry.xml


<remoteInstance url="https://localhost:9444/registry">

       <id>instanceid</id>

       <dbConfig>mounted_registry</dbConfig>
       <readOnly>false</readOnly>
       <enableCache>true</enableCache>
       <registryRoot>/</registryRoot>
       <cacheId>root@jdbc:mysql://localhost:3306/GregDB</cacheId>
</remoteInstance>

  • Add mount configurations to registry.xml

<mount path="/_system/config" overwrite="true">
       <instanceId>instanceid</instanceId>
       <targetPath>/_system/nodes</targetPath>
   </mount>

<mount path="/_system/governance" overwrite="true">
       <instanceId>instanceid</instanceId>
       <targetPath>/_system/governance</targetPath>
   </mount>

  • Enabling clustering in axis2.xml in $GREG_HOME/repository/conf/axis2 to send invalidation messages across WSO2 GREG and WSO2 ESB.

<clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="true"/>

  •  Sign in to the ESB server  using the default username and password (admin/admin) and browse the Registry. Now you should see the config and governance collections are updated with arrow icons as shown below

No comments:

Post a Comment