Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Mounting a Remote Repository (WSO2 GREG) to WSO2 ESB

DZone's Guide to

Mounting a Remote Repository (WSO2 GREG) to WSO2 ESB

Free Resource

The Integration Zone is brought to you in partnership with Cloud Elements.  What’s below the surface of an API integration? Download The Definitive Guide to API Integrations to start building an API strategy.

WSO2 Governance Registry [1] is basically a metadata repository which basically helps to store and manage metadata.  WSO2 Enterprise Service Bus (WSO2 ESB) [2] is an integration middle-ware tool which is virtually capable of interconnecting any enterprise software.

There several ways of mounting a remote repository to a WSO2 product (In this case WSO2 EB). You can find more information on [3]. In this post I am trying to explain, how to mount a remote repository to WSO2 ESB via JDBC-based configuration.

In this approach you have to move the local DB of the WSO2 GREG to an external DB. So any change you do the registry will be reflected in the external DB. In this example I will be using a MYSQL database.

Moving WSO2 GREG repository to external DB

  1. Create a new database schema (regdb), a new user (wso2carbon) with password (wso2carbon) and grant all permissions to wso2carbon.
  2.  Change the data source details of WSO2_CARBON_DB in master-datasources.xml file, which is located in GREG_HOME/repository/conf/datasources/, with your DB information.
    eg:
<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/regdb</url>
            <username>wso2carbon</username>
            <password>wso2carbon</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>
Start the server with -Dseup argument 
eg: 
./wso2server.sh -Dseup

This will setup all the tables in the DB and all the initial configurations needed. And WSO2 GREG is now ready with external registry.

Mounting remote repository to WSO2 ESB

  1. Add a new data source to the master-datasources.xml file, which is located in ESB_HOME/repository/conf/datasources/. NOTE: This entry is exactly same as the record we entered in WSO2 GREG, except for the <name> and <jndiConfig>/<name>
    eg:
<datasource>
    <name>WSO2_REG_DB</name>
    <description>The datasource used for registry and user manager</description>
    <jndiConfig>
        <name>jdbc/WSO2RegDB</name>
    </jndiConfig>
    <definition type="RDBMS">
        <configuration>
            <url>jdbc:mysql://localhost:3306/regdb</url>
            <username>wso2carbon</username>
            <password>wso2carbon</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 a new record <dbConfig> to registry.xml, which is located at ESB_HOME/repository/conf/
eg:
<dbConfig name="wso2remoteregistry">
    <dataSource>jdbc/WSO2RegDB</dataSource>
</dbConfig>
Uncomment the <remoteInstance> and <mount> sections in the registry.xml file and update with the correct details.
eg:
<remoteInstance url="https://localhost:9443/registry">
    <id>instanceid</id>
    <dbConfig>wso2remoteregistry</dbConfig>
    <readOnly>false</readOnly>
    <enableCache>true</enableCache>
    <registryRoot>/</registryRoot>
    <cacheId>wso2carbon@jdbc:mysql://localhost:3306/regdb</cacheId>
</remoteInstance>

<mount path="/_system/config/nodes" overwrite="true">
    <instanceId>instanceid</instanceId>
    <targetPath>/_system/nodes</targetPath>
</mount>
Start the WSO2 ESB. If you are running both WSO2 GREG and WSO2 ESB on same machine, you will have to set port offsets on one of them.eg:
./wso2server.sh -DportOffset=2

Once you start the WSO2 ESB, you should be able to access the remote repository from the WSO2 ESB.

To verify this go to resource browser of the admin console of the WSO2 ESB, https://localhost:9445, which you can find on the following URL if you start with postOffset=2

Then browse resources,

  1. You should find the mounted remote repository in _system/config/nodes with a folder icon having a blue arrow in it
  2.  You should find the mounted remote repository details on _system/local/repository/components/org.wso2.carbon.registry/mount

References:

[1] http://wso2.com/products/governance-registry/

[2] http://wso2.com/products/enterprise-service-bus/

[3] https://docs.wso2.org/display/Governance460/Remote+Instance+and+Mount+Configuration+Details

The State of API Integration Report provides data from the Cloud Elements platform and will help all developers navigate the recent explosion of APIs and the implications of API integrations to work more efficiently in 2017 and beyond.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}