Saturday, 26 November 2016

wso2 esb Dynamic Sequences : Step By Step Guide

Hi All,

Posting after a long time , have been occupied.

So today's post is an interesting one , it tells how to call sequences dynamically.

Here are the steps :

1. Create a dynamic sequence , i am going to use registry for this .

Login to wso2esb admin console, follow the steps in the images below :


Click on browse

Click on repository and click on Add resource 

Also create a sequence before hand which you want to call dynamically , create a xml file on your file system with sample content as follows , it can be anything you want.

<sequence  xmlns="http://ws.apache.org/ns/synapse" name="dynamicseq">
   <log level="custom">
     <property name="dynamic seq" value="called"/>
   </log>
</sequence>

Upload the file we created after add resource as shown below.



It will be uploaded as below :



This sequence can be called from any api or sequence as 

  <property name="seqName" value="conf:/repository/dynamicseq.xml"></property>
<sequence xmlns:ns="http://org.apache.synapse/xsd" key="{get-property('seqName')}"></sequence>

Just like my previous posts which are mostly on dynamic content (self bragging :P ) , the source of above mentioned property can be anything like database value or some evaluation of xpath or any thing for that matter and should resolve to a name like the value attribute above 

 conf:/repository/dynamicseq.xml

And the sequence key dynamic value can be passed as shown above {get-property('propertyName')}


When i execute the calling sequence or api following is logged

LogMediator dynamic seq = called

So it works , try and let me know if it works for you or revert if it doesn't i'll be glad to help

No comments:

Post a Comment