How to access system property from WSO2 ESB and Registry

前端 未结 2 1899
礼貌的吻别
礼貌的吻别 2021-01-17 01:42

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

相关标签:
2条回答
  • 2021-01-17 01:47

    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>
    
    0 讨论(0)
  • 2021-01-17 01:50

    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.

    0 讨论(0)
提交回复
热议问题