Wednesday, July 3, 2013

Mount WSO2 Governance Registry to WSO2 ESB with Read only Mode

As most of you all know, we have a product called WSO2 Governance Registry which is known as GReg to facilitate and cater the right level of structure straight out of the box to support SOA Governance, configuration governance, development process governance, design and run-time governance, life-cycle management, and team collaboration.

So in this example I am going to use our GReg as registry for WSO2 ESB's resources.

Furthermore, the main intention of this demonstration is to showcase "how to configure WSO2 ESB in Read Only/Read Write mode for WSO2 GReg. Following illustration shows the conceptual deployment architecture. Where we have two WSO2 ESB, First is on READ and WRITE mode(Offset 1) and the latter one is with READ only mode(offset 2).




Before dirt our hands!! we have to do some prerequisite tasks!! Yes first of all download the products from wso2 product site.

Well it is not enough, we have to setup underlying storage for WSO2 Greg to Demonstrate this sample. Thus, we will use MYSQL as a database.

So lets take a step ahead and do the work,

Step 1
Create a Database in mysql (Lets say database name as “gregMount”)
CREATE DATABASE gregMount;

Step 2
Grant the permission to the created database.

GRANT ALL ON gregMount.* TO regadmin@localhost IDENTIFIED BY "regadmin"

Alright, We have just finished the very basic step of this example!

Step 3
Well ESB and GReg need the MySql libraries to understand the MySql API. Thus put the MySQL driver into <home>/repository/components/lib/

Step 4
We will step into the Greg configuration Changes! Open up
<home>/repository/conf/datasources/master-datasources.xml

Add a data source that look like following 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/gregMount</url>
                    <username>regadmin</username>
                    <password>regadmin</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>

Step 5
Start the GReg first time with  <home>/bin sh wso2server.sh -Dsetup

Lets step into the WSO2 ESB and do the Read and Write mode configuration!

Step 6
Since we have used WSO2 GReg with default offset, we have to change the offset of the ESB (ReadWrite mode ESB) to <Offset>1</Offset>

In order to do this you have to change the default value of  Offset of  <home>/repository/conf/carbon.xml



Step 7

As mentioned bellow,add DataSource configuration into ESB's <home>/repository/conf/datasources/master-datasources.xml

     <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/gregMount</url>
                    <username>regadmin</username>
                    <password>regadmin</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>

Step 8
You need to do the following changes in the registry.xml that could be find in <home>/repository/conf/registry.xml.

Adding database configuration.

<dbConfig name="wso2registryRemort"> <dataSource>jdbc/WSO2CarbonDB_GREG</dataSource> </dbConfig>

add remote instance that point to Wso2 Greg
  <remoteInstance url="https://localhost:9443/registry">
        <id>instanceid</id>
        <dbConfig>wso2registryRemort</dbConfig>
        <readOnly>false</readOnly>
        <enableCache>true</enableCache>
        <registryRoot>/</registryRoot>
    </remoteInstance>

Mount the config and governance


  <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>



If you notice the remoteInstance configuration carefully, we have configured this ESB as readOnly false mode, it means we can Read and Write to the GReg.

Perfect!!! now we have completed almost everything that is needed for this demonstration. Lets see how to configure the Read only mode ESB in this demonstration.

Step 9
follow the above steps 6 to 8 to the second instance of ESB but make the Offset as <Offset>1</Offset> and Read only mode as True



Now you have the GReg and two ESB to test the Read only Mode

Test cases :- Try to add endpoint using ReadOnly ESB to registry.

No comments:

Post a Comment