MB 3.0.0 Configuration Management
As a team member of the upcoming WSO2 Message Broker, I had the privilege and opportunity to revive its configuration management model for the 3.0.0 release.
Previously on WSO2 MB ( 2.2.0 )..
Given that our product was heavily based on QPID to provide the AMQP protocol support, the configuration was mainly centered on qpid needs. Meaning our configurations were injected to their semantics, which considered multiple virtual host support and many other finer details related to the AMQP protocol. Our configuration properties were less in number and almost easily grouped under a couple of semantic tags within 2 files : "andes-config.xml" and "andes-virtualhosts.xml".
With MB 3.0.0, many more features and options were introduced within the product (e.g. multiple data store support, MQTT protocol support, improved cluster support, A new delivery mechanism based on slots [5]). Soon we realized that the existing configuration model will be quickly congested if we were to add properties related to all these features. So we decided to abstract away the AMQP configuration model and introduce our own configuration management module.
Expectations from the revamp
To maintain and unify all MB specific configurations through a single access point with a uniform access pattern.
To use more meaningful names for properties.
To organize properties in a sensible hierarchical manner for intuitive reference.
Separate external configurations coming from qpid sources
Verify and remove unused configurations (e.g. hector and zookeeper related ones) and cluster enabling from "andes-config.xml" (cos its now done with hazelcast)
Add new configurations introduced in v3.0.0
Current status of configuration files
According to the new model the main "broker.xml" contains links to the following sub configuration files :
PRODUCT_HOME/repository/conf/advanced/qpid-config.xml (absolutely QPID related configuration)
PRODUCT_HOME/repository/conf/advanced/virtualhosts.xml (absolutely QPID related configuration regarding virtual hosts)
And the broker.xml can also accommodate any other external config files through the <links> tag.
Removing unused properties
A special effort was carried out to identify any obsolete properties coming into MB 3.0.0 (renamed, unused, no-need-to-use) and such properties were removed. If you were feeling at home with MB 2.2.0 configuration, it may take a little time to figure out what has gone where in the new model, but we hope that our descriptive documentation should guide you to the light.
We have attempted to break down properties into semantic parent tags as much as possible. e,g, instead of using "andesContextStore" in virtualhosts.xml we can just use "contextStore". Instead of using "slotWindowSize" We can add a slot tag in which the "windowSize" property resides.
The "camelCase" naming pattern is used throughout.
Major sections added fresh to the new configuration module
<coordination><nodeID> : This can be used to override the auto-generated nodeID within an MB cluster.
Enable/disable transports : You can use the relevant sections under the <transports> tag to enable or disable mqtt/amqp transports within the MB instance.
Use custom authentication for MQTT : Through the <transports><mqtt><security> section.
Access Pattern (For the developer)
In past, the configuration properties were mainly accessed from the "org.wso2.andes.server.configuration.ServerConfiguration" class. This class was originally from qpid and has been modified to include our configurations too. The "andes-virtualhosts.xml" is read from the "business-messaging" component.
The new model exposes all these properties through a static container class and it is based on apache commons Configuration features [2] [3].
Given that "broker.xml" contains links to the sub config files, it is loaded as the primary configuration.
All sub configuration files are then combined reading through the "links" tag in "broker.xml"
Since the CompositeConfiguration class allows us to access any property from all the files after combining, We can then use XPath to read from the loaded CompositeConfiguration object.
All configuration properties are defined using an Enum format where each property has the following attributes :
keyInFile : xpath expression to find the property from CompositeConfiguration object.
dataType : expected datatype of the property
defaultValue : specified default value for the property in case it is not set in the files.
This enum-oriented design was based on [4]. IMO it reduces code duplication and gives a cleaner way to access properties than using string literals.
Given this design, a property can be parsed to its expected type and accessed by anywhere with the following statement :
AndesConfigurationManager.getInstance().getConfigurationValue(BrokerConfiguration.PERFORMANCE_TUNING_SLOTS_WINDOW_SIZE)
Refer attached image [7] for more details.
Since we use enums to define the properties, A single test case that iterates through all properties and reads them is sufficient to verify if any properties are faulty.
Since this implementation is heavily based on generics, the developer should be responsible when reading and writing properties of different data types. However, proper logging has been added to identify any such mismatches.
To sustain this model, it's really important that we do not drive towards a god code pattern, dumping all configurations under single sections. We need to continuously review additions so that they end up in a meaningful section.
You can always view, comment on the latest configuration file through link [6].
[1] : https://drive.google.com/file/d/0B1soNraLsHdmLW1manJFaDNDcjg/view?usp=sharing
[2] : http://www.code-thrill.com/2012/05/configuration-that-rocks-with-apache.html
[3] : http://java.dzone.com/articles/managing-configurations-apache
[4] : http://sett.ociweb.com/sett/settNov2012.html
[5] : http://sajinid.blogspot.co.nz/2015/03/wso2-message-broker-300-slot-based.html
[6] : https://github.com/wso2/carbon-business-messaging/blob/master/features/andes/org.wso2.carbon.andes.server.feature/resources/conf/broker.xml
[7] : https://drive.google.com/file/d/0B1soNraLsHdmcnN4VXdtU0dQQ0k/view?usp=sharing