Writing content into WSO2 Registry through WSO2 ESB mediators
ESB 4.9.0release we can achieve this directly using the property mediators registry scope.
ESB 4.8.1 there is no direct way to save content to registry through stock synapse mediators. This post describes two possible options we have with
ESB 4.8.1 to save content to the registry. Those are by using either the Script Mediator or the Class Mediator.
Following examples shows how to store the value of property
myProperty of type String in message context into the registry path
Achieving this with script mediator is relatively easy. Note that using the script mediator will have some performance impact on your mediation logic.
Here is a sample code snippet of a script mediator to save the value stored under
myProperty in message context to the registry.
First of all, you need to create a class mediator. You can follow this guide to write your own class mediator. After that what you need is to write some Java code similar to following to store the content into the registry.
To retrieve the stored content you can simply use the
get-property XPath function with
registry scope as follows.
<property name="regContent" expression="get-property('registry', 'conf:/store/myStore')"/>
Written by Asitha Nanayakkara