Mounting a Remote Repository (WSO2 GREG) to WSO2 ESB
Join the DZone community and get the full member experience.
Join For FreeWSO2 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
- Create a new database schema (regdb), a new user (wso2carbon) with password (wso2carbon) and grant all permissions to wso2carbon.
- 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>
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
- 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>
eg:
<dbConfig name="wso2remoteregistry"> <dataSource>jdbc/WSO2RegDB</dataSource> </dbConfig>
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>
./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,
- You should find the mounted remote repository in _system/config/nodes with a folder icon having a blue arrow in it
- 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
Opinions expressed by DZone contributors are their own.
Comments