How to access system property from WSO2 ESB and registry

My WSO2 ESB proxy service refers to an endpoint located at different URLs in different environments - DEV, TEST, PROD. According to the WSO2 documentation, I need to save the endpoint definition in the management registry and change the URL in the endpoint XML file in each environment. This may work great for organizations with 1 or 2 proxies, but it becomes significant overhead for 10+ proxies.

Another scenario is when I need to read certain environment properties in my ESB sequence.

Is there a way to define a bunch of properties in an external * .properties file and then read them in the ESB and Registry definitions?

0
source share
2 answers

You can access the system properties inside the ESB / proxy sequences using the broker script as follows:

<script language="js">mc.setProperty("file.separator",java.lang.System.getProperty("file.separator"));</script> <log level="custom"> <property name="file.separator" expression="get-property('file.separator')"/> </log> 

Here, the "file.separator" property is set as a property in the context of the message inside the mediator script and can be used in subsequent mediators.

You can also access the properties defined in the file in the ESB registry. For example, if you have a file in the configuration registry (test.xml) with the following content,

 <a>Helloo<b>World</b></a> 

The text element "World" in <b> can be obtained using the property broker as follows:

 <property name="test" expression="get-property('registry','conf:/test.xml')" scope="default" type="OM"/> <log level="custom"> <property name="test.b" expression="$ctx:test//b"/> </log> 
+7
source

here 's a blog post on how to access registry resources from classmeditor 1 . You can access any resources indicated in the message and make changes.

Similarly, you can save the external properties file and read it from the class and set all properties in the context of the synapse message using the meditaor class.

0
source

All Articles