Modifying config registry resource content during mediation in WSO2 ESB

别来无恙 提交于 2019-12-11 03:33:25

问题


I have a scenario where I need to store simple counter in config registry and increment it at end of sequence flow. Reason we need to store in config registry is in case server get restarted we have last counter value persisted. Can someone suggest how to increment the counter in config registry ?


回答1:


Sample javascript you can use in your mediation to save current message inside registry :

<script language="js"><![CDATA[
    importPackage(Packages.org.apache.synapse.config);
    mc.getConfiguration().getRegistry().newResource("gov:/trunk/mypath/MyResource.xml",false);
    mc.getConfiguration().getRegistry().updateResource("gov:/trunk/mypath/MyResource.xml",mc.getPayloadXML().toString());
]]></script>

newResource is used the first time to create the resource



来源:https://stackoverflow.com/questions/25688923/modifying-config-registry-resource-content-during-mediation-in-wso2-esb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!