0

My WSO2 ESB proxy service references an endpoint which is located at different URLs in various environments - DEV, TEST, PROD. According to the WSO2 documentation, I need to store the endpoint definition in the Governance Registry and modify the URL in endpoint XML file in each environment. That might work fine for the organizations with 1 or 2 proxies, but becomes a significant overhead for a 10+ proxies.

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

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

Community
  • 1
  • 1
Alex Yakimovich
  • 259
  • 1
  • 4
  • 17

2 Answers2

7

You can access system properties inside ESB sequences/proxy services using the script mediator 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 "file.separator" property is set as the property in the message context inside the script mediator and it can be used in subsequent mediators.

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

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

The text element "World" in <b> can be accessed using property mediator 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>
CharithaM
  • 166
  • 2
  • Thank you Charitha! This solves my problem with accessing external properties from the sequences. However, it looks like Endpoint's URL can not use properties via "get-property" function. Is there a way to get this attributes be property-driven? – Alex Yakimovich Mar 07 '13 at 19:17
  • You could define the URL of an endpoint in run time through setting "to" in the header. This may help you: http://stackoverflow.com/questions/15876410/wso2-esb-dynamically-change-endpoint-address – lsantsan Mar 24 '15 at 20:21
0

here is a blog post on how to access registry resources from a classmeditor1. You can access any resources as mentioned in the post and do modifications.

Likewise you can keep the external properties file and read that from the classmeditor and set all properties in synapse message context using class meditaor.

Ratha
  • 9,434
  • 17
  • 85
  • 163