Pages

Saturday, April 30, 2016

Setting up hot deployment for rules stored in registry in WSO2 BRS [Business Rule Server]

In most WSO2 products, we refer registry artifact instead packaging deployment artifacts in single CAPP when we need governance facilities over those artifacts. For example, more commonly we store WSO2 ESB Synapse Configuration of a sequence as a resource (or we can call registry artifact) and refer it in main Synapse configuration.

Likewise for WSO2 BRS rule services, we can store rules in the registry and refer them in rule service descriptor (.rsl file).

Simplest Method Of using registry artifacts

In such usage, in most cases in run-time, we read it, keep in cache, and reload when cache get invalidated. Therefore, when registry resource gets updated, it will affect to the run-time when cache gets invalidated.

Issue above method in case of rule service in WSO2 BRS

During rule service deployment, the rules in forms of .drl, .xls, .csv files, Inline or registry artifacts were read and inject those rules and build DroolsKnowledgeBase, since that is expensive process BRS cannot follow simple caching procedure.

There are two methods to update rules in run-time (without redeploying rule service)  rule service when registry resource get updated.

01. Manual method 

Publish message to relevant topic related to the registry resource.
Go to Main Tab click "Browse" under Topics. Then navigate to relavent topic (if your registry artifact path is gov:sharedRules/test then the topic resource path will be /registry/notifications/ResourceUpdated/_system/governance/sharedRules/test).

Click "details" to get details view.


02. Automatically updating rules

With this method when you update registry resources, relavent KnowledgeBases of each related rule services get reloasded. For achieve this, you have to little bit fiddle with WSO2 feature installation. But worth it, and this is kind of best useful way to update rules in run-time without un-deploying/redeploying rule service in production environment.

You just need to install following three features to WSO2 BRS:

  1. Apache Axis2 - Mail Transport -version1.1.0.wso2v17
  2. Registry Community Features - version 4.4.8
  3. Registry Handler Config - version 4.4.8
Note : Refer [1] to find how to install features for wso2 brs

This is tested in WSO2 BRS v2.2.0

[1] https://docs.wso2.com/display/BRS220/Installing+Features

No comments:

Post a Comment